How would i delete an object from a Many-to-Many relationship without removing the actual object?
I have the models
‘Mood’ has a many to many field
interests (which is a
I create an instance of
my_mood. In my_moods’s interests field I have
>>> my_mood.interests.all() [my_interest, ...]
How do I remove my_interest from my_mood without deleting either model instance? In other words, how do I remove the relationship without affecting the related models?
Note: you might have to get an instance of my_mood and my_instance using Django’s QuerySet API before you can execute this code.
If you need to remove all M2M references without touching the underlying objects, it’s easier to work from the other direction: