Code

Opened 5 years ago

Closed 5 years ago

#11737 closed (worksforme)

many2many recursive relationship do not work in DJ 1.1

Reported by: simon_gray99 Owned by: nobody
Component: Uncategorized Version: 1.1
Severity: Keywords: many2many recursive
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by Alex)

from the page at:

http://docs.djangoproject.com/en/dev/ref/models/fields/#recursive-relationships

the sample code does not work:

>>> from django.db import models
>>> class Person(models.Model):
...     name = models.CharField(max_length=20)
...     friends = models.ManyToManyField('self')
...     idols = models.ManyToManyField('self', symmetrical=False, related_name='stalkers')
...     def __unicode__(self):
...         return self.name
... 
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/django/db/models/base.py", line 51, in __new__
    kwargs = {"app_label": model_module.__name__.split('.')[-2]}
IndexError: list index out of range
>>> 

Attachments (0)

Change History (2)

comment:1 Changed 5 years ago by Alex

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Please use the preview button.

comment:2 Changed 5 years ago by russellm

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

I just tried this, and it works fine for me. There is also an extensive test suite of m2m relationships that covers this feature.

I don't doubt you have found a problem, but it's not as simple as "the sample code doesn't work". Feel free to reopen if you can provide more context or debugging assistance.

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.