Opened 17 months ago

Last modified 17 months ago

#26678 new Cleanup/optimization

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

Reported by: Antonin Owned by: nobody
Component: Documentation Version: master
Severity: Normal Keywords: add ManyToMany
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
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 (4)

comment:1 Changed 17 months ago by Simon Charette

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 Changed 17 months ago by Antonin

Patch needs improvement: unset

comment:3 Changed 17 months ago by Tim Graham

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

comment:4 Changed 17 months ago by Tim Graham

Patch needs improvement: set
Note: See TracTickets for help on using tickets.
Back to Top