#1379 closed defect (fixed)
get_relatedobject fails with ForeignKey("self")
Reported by: | 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.
Note:
See TracTickets
for help on using tickets.
Fixed on r2446.
(tests.modeltests.m2o_recursive)