How to update ManyToManyField when source model is deleted?

Consider this model.py for a MariaDB-based setup:

class User(models.Model):
    email = models.CharField(max_length=255)

class Newsletter(models.Model):
    subscribers = models.ManyToManyField(User, blank=True)
    title       = models.CharField(max_length=255)

If I delete a User, I want the reference to it removed from any Newsletter's subscribers list. I do not want to delete the Newsletter itself at any point, even if the subscribers list is empty.

Is this possible automatically with some Django feature like on_delete=REMOVE_FROM_LIST?

Back to Top