[Django]-Many to many relationship in django database model

0👍

When accessing a specific model instance (and not the model’s manager) you access related items with modelname_set instead of modelname. For example:

>>> user_detail.roles_set.remove(my_role)
>>> user_detail.roles_set.all()
<QuerySet []>

Docs:

https://docs.djangoproject.com/en/2.1/topics/db/examples/many_to_many/

👤Athena

Leave a comment