Opened 17 years ago

Closed 16 years ago

Last modified 16 years ago

#3914 closed (duplicate)

Self-referencing keys in the list_display kills development server with no error thrown

Reported by: adamfast@… Owned by: nobody
Component: contrib.admin Version: dev
Severity: Keywords: self-reference list_display
Cc: None Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Adrian Holovaty)

If you use this model:

class Page(models.Model):
    title = models.CharField(maxlength=192)
    default = models.BooleanField()
    template = models.CharField(maxlength=256)
    parent = models.ForeignKey('Page')
    sequence = models.IntegerField()
    visible_on_menu = models.BooleanField()
    defined_header = models.CharField(maxlength=256)
    date_of_creation = models.DateTimeField()
    class Admin:
        list_display = ['title','parent','visible_on_menu']

And try to go to the model in the admin interface, the development server just dies. There is no error, it just goes back to a command prompt waiting.

This model is to be used for a newforms-like setup that can have parent/child pages for building heirarchical navigation menus - and it will be handy to see the parent in the display.

Change History (8)

comment:1 by Adrian Holovaty, 17 years ago

Description: modified (diff)

(Fixed formatting in description.)

comment:2 by Simon G. <dev@…>, 17 years ago

Triage Stage: UnreviewedAccepted

Yep. Confirmed on r4921.

comment:3 by Malcolm Tredinnick, 17 years ago

Whilst this is something we might be able to fix, the workaround -- and the way the documentation recommends to do this -- is to use "self" instead of "Page" in the ForeignKey.

comment:4 by Simon G. <dev@…>, 17 years ago

This might be something that django.core.management.validate could check for and display a warning?

comment:5 by anonymous, 17 years ago

Cc: None added
Keywords: None added; self-reference list_display removed
Summary: Self-referencing keys in the list_display kills development server with no error thrownNone
Triage Stage: AcceptedDesign decision needed
Version: SVNother branch

comment:6 by Ramiro Morales, 17 years ago

Keywords: self-reference list_display added; None removed
Summary: NoneSelf-referencing keys in the list_display kills development server with no error thrown
Triage Stage: Design decision neededAccepted
Version: other branchSVN

Undo anonymous breakage

comment:7 by Ramiro Morales, 16 years ago

Resolution: duplicate
Status: newclosed

Marking as duplicate of #4212 because a) this ticket has muted on being about the same issue and b) it has a couple of useful comments about things to consider before implementing validation of FK-to-self declarations.

comment:8 by Ramiro Morales, 16 years ago

Oops, second try: Marking as duplicate of #4212 because a) it has a couple of useful comments about things to consider before implementing validation of FK-to-self declarations and b) this ticket has mutated to being about the same issue.

Note: See TracTickets for help on using tickets.
Back to Top