Opened 11 years ago

Closed 11 years ago

#3764 closed (duplicate)

select_related() raises RuntimeError with ForeignKey('self') when record linked to itself

Reported by: anonymous Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version: master
Severity: Keywords: select_related, admin, maximum recursion, ForeignKey
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


class Person(models.Model):
    name = models.CharField(maxlength=100)
    advocate = models.ForeignKey('self', null = False, related_name = 'customers')

person = Person.objects.create(name="First", advocate_id = 0)
person.advocate = person



will raise RuntimeException: maximum recursion depth exceeded in cmp

Admin are of web-site also becomes frozen when you try to open 'Persons' page

Change History (1)

comment:1 Changed 11 years ago by (removed)

Resolution: duplicate
Status: newclosed

This is a duplicate of 3288 (which is reviewed/accepted).

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