I am using a ManyToManyField and want to be able to clear it.
This is my current code (Yes, I do override the save method of the same Object Class)
def save(self, *args, **kwargs):
if self.maxparticipants == 0:
self.participants.clear()
super(Event, self).save(*args, **kwargs)
What it does:
It checks if the maxparticipant count is 0 (so there is no participant allowed) and if it's true it should remove every participant from the m2m. When printing self.participants.all() I get Queryset([]) - it works fine.... in theory because it won't get written to the database :/
If you need more details just add a comment :)