I have a few recursive Django ManytoManyField's that use the 'through attribute' in my app. here is an example:
class Author(models.Model):
user = models.OneToOneField(User, parent_link=True)
introduction = models.TextField(blank=True)
pictures = models.ManyToManyField('Graphic', related_name='users', null=True)
organizations = models.ManyToManyField('Organization', related_name='members')
expertise = models.ManyToManyField('Tag', related_name='experts', null=True)
interests = models.ManyToManyField('Tag', related_name='interested_in', null=True)
saved_articles = models.ManyToManyField(Article, related_name='favorited_by', null=True, through='SavedArticles')
authors_followed = models.ManyToManyField('self', related_name='authors_followed', null=True, through='FollowedAuthors', symmetrical=False)
class FollowedAuthors(models.Model):
author = models.ForeignKey(Author)
trustee = models.ForeignKey(Author)
notes = models.TextField()
tags = models.ManyToManyField('Tag')
I know I could access MyAuthor.authors_followed.all(), but if I wanted call FollowedAuthor.authors_followed.all() to return MyAuthor, couldn't I just use related_name='authors_followed'? Does that just negate the symmetrical=False behavior?
A similar question was asked here, but in that case they had:
recursive_field = models.ManyToManyField('self', through='ThroughTable', related_name='different_field').
Am I missing some understanding of how symmetrical and related_name work?