Opened 7 years ago

Closed 6 years ago

Last modified 6 years 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 by Jeremy Lainé, 7 years ago

Description: modified (diff)

comment:2 by Tim Graham, 7 years ago

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 by Bartosz Grabski, 6 years ago

Owner: changed from nobody to Bartosz Grabski
Status: newassigned

comment:4 by Bartosz Grabski, 6 years ago

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

comment:5 by Jeremy Lainé, 6 years ago

Owner: set to Jeremy Lainé
Status: newassigned

comment:6 by Jeremy Lainé, 6 years ago

Has patch: set

I have add 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.

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

Version 0, edited 6 years ago by Jeremy Lainé (next)

comment:7 by Jeremy Lainé, 6 years ago

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 6 years ago by Jeremy Lainé (previous) (diff)

comment:8 by Johannes Maron, 6 years ago

Triage Stage: AcceptedReady for checkin

comment:9 by Tim Graham <timograham@…>, 6 years ago

Resolution: fixed
Status: assignedclosed

In 74179296:

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

comment:10 by Tim Graham <timograham@…>, 6 years ago

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