[Fixed]-AttributeError: 'RelatedManager' object has no attribute 'remove'

14👍

Cannot be null

The documentation for RelatedManager.remove() says

For ForeignKey objects, this method only exists if null=True.
If the related field can’t be set to None (NULL), then
an object can’t be removed from a relation without being added to another.

Obvious, once you think about it.
What I really intended to do was this:

publisher.publisherperson_set.filter(email__in=pp_remove_set).delete()

14👍

Just posting this since I got here from a related search
AttributeError: 'RelatedManager' object has no attribute 'delete'

What I was looking for was:

thing.stuff_set.all().delete()

note: still learning django, but i’m assuming any queryset operations filter, all, order_by, exclude, annotate, etc

can be used. Although I’m not sure at the moment what sort of nuance there is in regards to the queryset list return from all() and the stuff_set:

Leave a comment