In one model, I have this:
class MyModel(models.Model):
relations = models.ManyToManyField(OtherModel)
....
and if I choose:
my_object.relations.remove(other_model_object)
it works.
How to remove all objects from the relations? my_object.relations.clean() is not working.
First, you’ll need to clear the relationship(s) by using .clear() or .remove(), whichever suits your needs better according to the docs.
After that, you’ll need to delete the object(s) by using the [YourModel].delete() method.