Code

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#1379 closed defect (fixed)

get_relatedobject fails with ForeignKey("self")

Reported by: ng@… Owned by: adrian
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: UI/UX:

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.

Attachments (0)

Change History (1)

comment:1 Changed 8 years ago by jdunck@…

  • Resolution set to fixed
  • Status changed from new to closed

Fixed on r2446.
(tests.modeltests.m2o_recursive)

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.