#29440 closed Bug (fixed)
Document that RelatedManager.set() doesn't accept bulk keyword argument for many-to-many relations
Reported by: | Jeremy Lainé | Owned by: | Jeremy Lainé |
---|---|---|---|
Component: | Documentation | Version: | 2.0 |
Severity: | Normal | Keywords: | |
Cc: | Bartosz Grabski | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Since Django 2.0, trying to pass bulk=True to a many-to-many RelatedManager results in an error:
TypeError: set() got an unexpected keyword argument 'bulk'
The documentation however still states that the "bulk" argument exists, so I'm not sure whether the documentation or the code is wrong.
Looking at the django code, the set() method for reverse many-to-one, and forward many-to-many relations don't have the same signature.
In create_reverse_many_to_one_manager
:
def set(self, objs, *, bulk=True, clear=False):
In create_forward_many_to_many_manager
:
def set(self, objs, *, clear=False):
Change History (10)
comment:1 Changed 3 years ago by
Description: | modified (diff) |
---|
comment:2 Changed 3 years ago by
Component: | Database layer (models, ORM) → Documentation |
---|---|
Summary: | RelatedManager.set() doesn't accept bulk keyword argument for many-to-many relations → Document that RelatedManager.set() doesn't accept bulk keyword argument for many-to-many relations |
Triage Stage: | Unreviewed → Accepted |
comment:3 Changed 3 years ago by
Owner: | changed from nobody to Bartosz Grabski |
---|---|
Status: | new → assigned |
comment:4 Changed 3 years ago by
Cc: | Bartosz Grabski added |
---|---|
Owner: | Bartosz Grabski deleted |
Status: | assigned → new |
comment:5 Changed 3 years ago by
Owner: | set to Jeremy Lainé |
---|---|
Status: | new → assigned |
comment:6 Changed 3 years ago by
Has patch: | set |
---|
I have added a PR, which tries to make the "bulk" argument more consistently documented:
- the signatures for clear() and remove() did not reference "bulk" at all
- I added a note in clear(), remove() and set() to the effect that the "bulk" argument does not exist for many-to-many relations.
comment:7 Changed 3 years ago by
In the process, I discovered that for one-to-many relations, the "bulk" argument is correctly passed down to add() and remove(), but not to clear(). This looks like a bug, I have opened issue #29447.
comment:8 Changed 3 years ago by
Triage Stage: | Accepted → Ready for checkin |
---|
I believe the documentation should be updated similar to abe6c5defefc7057e7fb5f47b79643f7b89f7d90.