Opened 18 years ago

Closed 18 years ago

Last modified 18 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

Description

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.

Example:

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 by jdunck@…, 18 years ago

Resolution: fixed
Status: newclosed

Fixed on r2446.
(tests.modeltests.m2o_recursive)

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