Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#26679 closed Cleanup/optimization (fixed)

Document which methods are disabled on RelatedManager if there's an intermediate tables

Reported by: Baptiste Mispelon Owned by: Ketan Bhatt
Component: Documentation Version: 1.9
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The note at https://docs.djangoproject.com/en/dev/ref/models/relations/#django.db.models.fields.related.RelatedManager.set says:

Also, if you are using an intermediate model for a many-to-many relationship, some of the related manager’s methods are disabled.

It would be helpful to know exactly which methods are disabled.
From what I understand, add, create, and remove are disabled, but clear works.
The linked documentation (https://docs.djangoproject.com/en/1.9/topics/db/models/#intermediary-manytomany) doesn't mention set at all.

Change History (7)

comment:1 by Tim Graham, 9 years ago

Summary: Improve reference documentation for RelatedManager and intermediate tablesDocument which methods are disabled on RelatedManager if there's an intermediate tables
Triage Stage: UnreviewedAccepted

comment:2 by Ketan Bhatt, 9 years ago

Owner: changed from nobody to Ketan Bhatt
Status: newassigned

It says here that:

  1. "Unlike normal many-to-many fields, you can’t use add(), create(), or set() to create relationships"
  2. "The remove() method is disabled"
  3. "However, the clear() method can be used"

Should I link to this part of the documentation in the note in Related objects Reference, or just state that only clear() can be used?

Last edited 9 years ago by Ketan Bhatt (previous) (diff)

comment:3 by Baptiste Mispelon, 9 years ago

You're right, I was incorrect and set() is indeed mentionned (turns out I was reading the 1.9 version of the docs instead of the latest).

To me, it would be helpful to have the list of disabled method explicitly listed (that's what I expect from a reference documentation).
I was thinking of something along the lines of "[...] some of the related manager's methods are disabled (add, create, and set)".

What do you think?

Thanks.

in reply to:  3 comment:4 by Ketan Bhatt, 9 years ago

Replying to bmispelon:

You're right, I was incorrect and set() is indeed mentionned (turns out I was reading the 1.9 version of the docs instead of the latest).

To me, it would be helpful to have the list of disabled method explicitly listed (that's what I expect from a reference documentation).
I was thinking of something along the lines of "[...] some of the related manager's methods are disabled (add, create, and set)".

What do you think?

Take a look at https://github.com/django/django/pull/6677 and tell me if that looks good to you

Thanks.

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

Resolution: fixed
Status: assignedclosed

In 59523c06:

Fixed #26679 -- Documented which methods are disabled on RelatedManager if there's an intermediate table.

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

In c2dde75:

[1.10.x] Fixed #26679 -- Documented which methods are disabled on RelatedManager if there's an intermediate table.

Backport of 59523c06fe482232dad9dc63ef0baab63418196d from master

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

In d4266dca:

[1.9.x] Fixed #26679 -- Documented which methods are disabled on RelatedManager if there's an intermediate table.

Backport of 59523c06fe482232dad9dc63ef0baab63418196d from master

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