14👍
✅
Cannot be
Cannot be null
The documentation for RelatedManager.remove()
says
For
ForeignKey
objects, 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()
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
:
- Can't pip install mysql-python
- How to get all objects by instance in django
- Store browser tab specific data
Source:stackexchange.com