Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#32372 closed Cleanup/optimization (fixed)

Improve consistency in "Related objects reference" docs.

Reported by: Jack Aitken Owned by: Jack Aitken
Component: Documentation Version: 3.1
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

I have a suggested clarification in the docs, under the "Related objects reference" section: https://docs.djangoproject.com/en/3.1/ref/models/relations/.

One of the first examples of a ManyToMany field relationship begins with an example of a Pizza model and a Toppings model, but in the shell example below it demonstrates this relationship with two different models: a Blog model and an Entry model.

I've read through this section a few times so I apologize in advance if I'm incorrect in my understanding, but in my opinion it would be clearer to stick with one set of classes for both the examples. If choosing to continue with the Pizza and Toppings example, I would suggest changing the example shown in the shell as follows:

>>> t = Topping.objects.get(id=1)
>>> p = Pizza.objects.get(id=5)
>>> t.pizza_set.add(p) # Associates Topping t with Pizza p.

If this is agreeable, I would love to make this change.

Change History (11)

comment:1 by Jack Aitken, 4 years ago

Type: UncategorizedCleanup/optimization

comment:2 by Mariusz Felisiak, 4 years ago

Easy pickings: set
Owner: changed from nobody to Jack Aitken
Status: newassigned
Summary: Clarification of "RelatedManager" class exampleImprove consistency in "Related objects reference" docs.
Triage Stage: UnreviewedAccepted

Examples in this page use reverse relation for a ForeignKey not a ManyToManyField, so the be more consistent we could change change the Reporter - Article example to Blog - Entry, e.g.:

class Blog(models.Model):
    # ...
    pass

class Entry(models.Model):
    blog = models.ForeignKey(Entry, on_delete=models.CASCADE)

in reply to:  2 comment:3 by Jack Aitken, 4 years ago

Replying to Mariusz Felisiak:

Apologies, this is my first contribution so I'm still learning a lot. I've followed the Advice for new contributors as well as Writing documentation. I've now built the html files using Sphinx but when I try to git add relations.html from /docs/_build/html/ref/models I get an error:

The following paths are ignored by one of your .gitignore files:
docs/_build/html/ref/models/relations.html

Sorry! Any help you can give would be really appreciated.

comment:4 by Tim Graham, 4 years ago

Only the source files for the docs are stored in version control. You can build the docs locally for testing, but you shouldn't put anything from docs/_build in your commit.

comment:5 by Jack Aitken, 4 years ago

Has patch: set

Thanks, Tim!

PR was made here is the link: PR #13926

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

Resolution: fixed
Status: assignedclosed

In 59c63c7f:

[3.2.x] Fixed #32372 -- Made examples in related objects reference docs consistent.

Backport of 725c549ae7a34d83447201da7190f8d71c7fc2fc from master

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

In 725c549:

Fixed #32372 -- Made examples in related objects reference docs consistent.

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

In cc5ee23f:

[3.1.x] Fixed #32372 -- Made examples in related objects reference docs consistent.

Backport of 725c549ae7a34d83447201da7190f8d71c7fc2fc from master

comment:9 by GitHub <noreply@…>, 4 years ago

In 2b4b6c8a:

Refs #32372 -- Updated manager name in related objects reference docs.

Follow up to 725c549ae7a34d83447201da7190f8d71c7fc2fc.

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

In c708837a:

[3.2.x] Refs #32372 -- Updated manager name in related objects reference docs.

Follow up to 725c549ae7a34d83447201da7190f8d71c7fc2fc.
Backport of 2b4b6c8af0aae8785bc1347cf1be2e8e70fd5ff3 from master

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

In 18adc89e:

[3.1.x] Refs #32372 -- Updated manager name in related objects reference docs.

Follow up to 725c549ae7a34d83447201da7190f8d71c7fc2fc.
Backport of 2b4b6c8af0aae8785bc1347cf1be2e8e70fd5ff3 from master

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