Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#1379 closed defect (fixed)

get_relatedobject fails with ForeignKey("self")

Reported by: ng@… Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version: 0.91
Severity: major Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


When a model class has a one-to-many relationship with itself, the get_relatedobject methods of the many-side classes will be overwritten by the method of the one-side's class.


class Test(meta.Model):

parent = meta.ForeignKey('self', blank=True, null=True)

Create two objects of that kind, set one to be the parent of the other, then try test.get_parent() on the child object. A UnitDoesNotExists exception will be raised.

Change History (1)

comment:1 Changed 13 years ago by jdunck@…

Resolution: fixed
Status: newclosed

Fixed on r2446.

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