Opened 3 years ago

Closed 3 years ago

#20970 closed Cleanup/optimization (fixed)

Related fields docs improvements

Reported by: Anssi Kääriäinen Owned by: Matthew Rich
Component: Documentation Version: master
Severity: Normal Keywords: afraid-to-commit
Cc: matthew@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The docs at https://docs.djangoproject.com/en/dev/ref/models/relations/ say that "In the example above, e.save() is called to perform the update." However, the example above doesn't contain .save() call at all.

In addition it might be worth it to note that all of the methods apply the change to the database instantly.

Still, I don't see a mention of direct association, that is e.entry_set = some_list. This is often the fastest way to update a relationship.

Creating separate patches for these issues might be better than doing them all in one go.

Change History (8)

comment:1 Changed 3 years ago by Tim Graham

What's meant by the first sentence is that when you execute b.entry_set.add(e), Django calls e.save() to perform the update. I guess this can be clarified if it isn't clear.

comment:2 Changed 3 years ago by Anssi Kääriäinen

Nah, no need to do that, I just didn't manage to read that correctly.

comment:3 Changed 3 years ago by Daniele Procida

Keywords: afraid-to-commit added

So improvements still in order include:

  • a mention of direct association, that is e.entry_set = some_list, which is often the fastest way to update a relationship.
  • a note that all the methods discussed - add, create, remove, clear - apply database changes immediately

comment:4 Changed 3 years ago by Matthew Rich

Owner: changed from nobody to Matthew Rich
Status: newassigned

comment:5 Changed 3 years ago by Matthew Rich

Tackling this ticket at Djangocon sprints.

comment:6 Changed 3 years ago by Matthew Rich

Cc: matthew@… added
Resolution: fixed
Status: assignedclosed

Pull request submitted.

comment:7 Changed 3 years ago by Aymeric Augustin

Has patch: set
Resolution: fixed
Status: closednew

Please don't mark tickets as fixed until a fix is actually merged in the master branch; use the "has patch" flag instead. Thank you!

comment:8 Changed 3 years ago by Tim Graham

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top