Django

Code

Ticket #2023 (closed: fixed)

Opened 2 years ago

Last modified 5 months ago

"View on site" breaks when model specifies primary key other than ID

Reported by: emeraldjunk-django@yahoo.com Assigned to: adrian
Milestone: Component: Admin interface
Version: SVN Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

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.

Attachments

Change History

05/30/06 20:59:17 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

(In [3009]) Fixed #2023 -- 'View on site' now works with non-integer primary keys.

06/12/06 05:56:07 changed by Go

  • type deleted.
  • summary changed from "View on site" breaks when model specifies primary key other than ID to "View on site" breaks when model specifies primary key other than ID.

01/28/08 00:05:59 changed by gwilson

  • summary changed from "View on site" breaks when model specifies primary key other than ID to "View on site" breaks when model specifies primary key other than ID.

Add/Change #2023 ("View on site" breaks when model specifies primary key other than ID)




Change Properties
Action