I am using a ManyToManyField whose target is a 'self' reference, but it 
does not create a related_name "reverse" field.

Here is my model:

class SecurityGroup(models.Model):
    name = models.CharField(max_length=100) 
    description = models.TextField() 
    subgroups = models.ManyToManyField('self', related_name='origin') 

    def __str__(self): 

        return self.name


And here is the problem:


>>> x = SecurityGroup(name='name', description='description')
>>> x.save()
>>> x.origin()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'SecurityGroup' object has no attribute 'origin'


There also no x.securitygroup_set. Is this a bug?



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9a8d0c8c-9429-4340-be69-78b8e6a5a296%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to