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?
null
The documentation for RelatedManager.remove() says
For
ForeignKeyobjects, this method only exists ifnull=True. If the related field can’t be set toNone(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()
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With