AttributeError: 'RelatedManager' object has no attribute 'remove'

Viewed 13521

Somewhere in my code it says

publisher.publisherperson_set.remove(email__in=pp_remove_set)

Upon executing this, I got

AttributeError: 'RelatedManager' object has no attribute 'remove'

And indeed: I looked at dir(publisher.publisherperson_set) and it had plenty of operations (including add), but not remove.

Under which circumstances is this possible?

2 Answers

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:

Related