Use Scenario One:
If the ManayTOManay field in a table is associated with itself, that is, out of the item such code:
ManyToManyField(self)
Then, you need to be aware that when you add a self object to the field using the add method, it automatically creates a mutual association between the two parties.
Example:
There is a field for friendships, with many-to-many associations to itself, the
friends = ('self')
When you add an object using friends .add(), the association between the two parties is automatically established.
To disable this, a symmetrical parameter needs to be added and set to False, as referenced below:
('self', blank=True, symmetrical=False)
Usage Scenario Two:
If there are more than one ManayTOManay field in a table associated to the same another table, the other table will not be able to find it accurately in the reverse query, in order to solve this problem, you need to add a parameter related_name to the many-to-many field and name it differently from the other many-to-many fields, for example:
('self', related_name='user_attentions')
Refer to the following:
There's a table named A
There's a table named B
A has multiple many-to-many fields associated with B. One of the fields, related_name, has a value of user_attentions.
When B performs a reverse query, it is sufficient to use the B.user_attentions query
Above this article based on the django ManyToMany use of the precautions in detail is what I share with you all the content, I hope to give you a reference, and I hope you support me more.