Opened 18 years ago
Closed 17 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: | dev |
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: | no | UI/UX: | no |
Description
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.save() person.advocate = person person.save()
Then
Person.objects.all().select_related()
will raise RuntimeException: maximum recursion depth exceeded in cmp
Admin are of web-site also becomes frozen when you try to open 'Persons' page
Note:
See TracTickets
for help on using tickets.
This is a duplicate of 3288 (which is reviewed/accepted).