Opened 9 years ago

Closed 6 years ago

Last modified 6 years ago

#26678 closed Cleanup/optimization (fixed)

Document that ManyRelatedManager.add()/remove() can take primary keys

Reported by: Antonin Owned by: Tobias Kunze
Component: Documentation Version: dev
Severity: Normal Keywords: add ManyToMany
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The documentation does not mention that the add method can be called with primary keys instead of model instances:
https://docs.djangoproject.com/en/dev/ref/models/relations/#django.db.models.fields.related.RelatedManager.add

This is only documented in the code:
https://github.com/django/django/blob/master/django/db/models/fields/related_descriptors.py#L984

I will file a PR regarding this issue.

Change History (8)

comment:1 by Simon Charette, 9 years ago

Has patch: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted
Version: 1.9master

PR that could be improved based on received feedback about the similar behavior of remove() and it's docstring.

comment:2 by Antonin, 9 years ago

Patch needs improvement: unset

comment:3 by Tim Graham, 9 years ago

Summary: Precision in the documentation about the add method for ManyToMany fields.Document that ManyRelatedManager.add()/remove() can take primary keys

comment:4 by Tim Graham, 9 years ago

Patch needs improvement: set

comment:5 by Tobias Kunze, 6 years ago

Owner: changed from nobody to Tobias Kunze
Patch needs improvement: unset
Status: newassigned

comment:6 by Mariusz Felisiak <felisiak.mariusz@…>, 6 years ago

Resolution: fixed
Status: assignedclosed

In a44a21a2:

Fixed #26678 -- Doc'd that RelatedManager.add()/remove()/set() accepts the field the relation points to.

comment:7 by Mariusz Felisiak <felisiak.mariusz@…>, 6 years ago

In 0e2ed4fd:

Refs #26678 -- Added tests for using the field the relation points to with RelatedManager.add()/remove()/set().

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 6 years ago

In 769f87f:

[2.2.x] Fixed #26678 -- Doc'd that RelatedManager.add()/remove()/set() accepts the field the relation points to.

Backport of a44a21a22f20c1a710670676fcca798dd6bb5ac0 from master

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