Opened 15 months ago

Closed 15 months ago

Last modified 15 months ago

#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 Jeremy Lainé)

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 15 months ago by Jeremy Lainé

Description: modified (diff)

comment:2 Changed 15 months ago by Tim Graham

Component: Database layer (models, ORM)Documentation
Summary: RelatedManager.set() doesn't accept bulk keyword argument for many-to-many relationsDocument that RelatedManager.set() doesn't accept bulk keyword argument for many-to-many relations
Triage Stage: UnreviewedAccepted

I believe the documentation should be updated similar to abe6c5defefc7057e7fb5f47b79643f7b89f7d90.

comment:3 Changed 15 months ago by Bartosz Grabski

Owner: changed from nobody to Bartosz Grabski
Status: newassigned

comment:4 Changed 15 months ago by Bartosz Grabski

Cc: Bartosz Grabski added
Owner: Bartosz Grabski deleted
Status: assignednew

comment:5 Changed 15 months ago by Jeremy Lainé

Owner: set to Jeremy Lainé
Status: newassigned

comment:6 Changed 15 months ago by Jeremy Lainé

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.

https://github.com/django/django/pull/9982

Last edited 15 months ago by Jeremy Lainé (previous) (diff)

comment:7 Changed 15 months ago by Jeremy Lainé

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.

Last edited 15 months ago by Jeremy Lainé (previous) (diff)

comment:8 Changed 15 months ago by Johannes Hoppe

Triage Stage: AcceptedReady for checkin

comment:9 Changed 15 months ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In 74179296:

Fixed #29440 -- Doc'd where the bulk argument applies in RelatedManager.

comment:10 Changed 15 months ago by Tim Graham <timograham@…>

In 36c35aba:

[2.1.x] Fixed #29440 -- Doc'd where the bulk argument applies in RelatedManager.

Backport of 741792961815cf4a95c5ce8ab590dfc7700c6153 from master

Note: See TracTickets for help on using tickets.
Back to Top