Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#1826 closed defect (duplicate)

Model crashes with ForeignKey('self') and a field with the same name

Reported by: Stefano J. Attardi <django@…> Owned by: Adrian Holovaty
Component: contrib.admin Version: master
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


The following model will fail on install:

class Test(models.Model):
    this = models.ForeignKey("self")
    test = models.TextField()
    class Admin: pass

with this message:

At least one field in Test should have core=True, because it's being edited inline by test.Test.

If you add core=True as the message suggests:

class Test(models.Model):
    this = models.ForeignKey("self")
    test = models.TextField(core=True)
    class Admin: pass

then the admin crashes on the add page with the following error:

Exception Type:	AttributeError
Exception Value:	'bool' object has no attribute 'get'
Exception Location:	django\db\models\ in get_manipulator_fields, line 112

Change History (2)

comment:1 Changed 12 years ago by Stefano J. Attardi

Resolution: duplicate
Status: newclosed

See #1839.

comment:2 Changed 11 years ago by James Bennett

(In [4673]) 0.91-bugfixes: Fixed #999 by resolving name clash in the metasystem which could confuse manipulators about which fields they should follow. Refs #1808, #1826, #1839 and #2415, which are variations of this that persist in trunk.

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