I'm using on my BlogPost model the ParentalManyToManyField on the Model itself via self.
And I just realized that the field causes related Pages to update other Pages.
Similar to what would happen when using ManyToManyField with symmetrical=True
class BlogPost(Page):
related_posts = ParentalManyToManyField(
"self", blank=True, related_name="related_blog_posts"
)
from blog.models import PostPage
one = PostPage.objects.get(id=1)
two = PostPage.objects.get(id=2)
three = PostPage.objects.get(id=3)
one.related_posts.all()
Out[6]: <PageQuerySet []>
two.related_posts.all()
Out[7]: <PageQuerySet []>
one.related_posts.add(one)
one.related_posts.all()
Out[9]: [<PostPage: Post 1>]
two.related_posts.add(one)
two.related_posts.all()
Out[12]: [<PostPage: Post 1>]
two.related_posts.add(three)
two.related_posts.all()
Out[16]: [<PostPage: Post 1>, <PostPage: Post 3>]
one.save()
five.save()
one.related_posts.all()
Out[18]: <PageQuerySet [<PostPage: Post 1>, <PostPage: Post 2>]>
two.related_posts.all()
Out[19]: <PageQuerySet [<PostPage: Post 1>, <PostPage: Post 3>]>
So I assumed I have to use symmetrical=False. But this seems to have no effect. Am I' missing something or misunderstood the concept of ParentalManyToManyField?
I'm using on my BlogPost model the
ParentalManyToManyFieldon the Model itself viaself.And I just realized that the field causes related Pages to update other Pages.
Similar to what would happen when using
ManyToManyFieldwithsymmetrical=TrueSo I assumed I have to use
symmetrical=False. But this seems to have no effect. Am I' missing something or misunderstood the concept ofParentalManyToManyField?