Model A:
class Photo(models.Model):
title = models.CharField(maxlength = 50)
slug = models.SlugField('Slug', prepopulate_from = ('title',),
help_text='Use auto-suggestion or a simple text string.',
)
[...more stuff, ImageField, etc...]
Model B:
class Photo(models.Model):
title = models.CharField(maxlength = 50)
slug = models.SlugField('Slug', prepopulate_from = ('title',),
help_text='Use auto-suggestion or a simple text string.',
primary_key='True')
[...more stuff, ImageField, etc...]
Model A works fine in the admin (i.e. you can click on "View on site" and you can view the photo), Model B however gives you a 404. Looking at the relevant entry for urls.py from the admin it seems that this expects a numerical primary key and therefor breaks when e.g. the slug becomes primary key.
Note: using the slug as primary key came from copy-and-pasting an example I found on the web, not sure if this frowned upon anyway.