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.
--
Ticket URL: <https://code.djangoproject.com/ticket/32372>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* type: Uncategorized => Cleanup/optimization
--
Ticket URL: <https://code.djangoproject.com/ticket/32372#comment:1>
* owner: nobody => Jack
* status: new => assigned
* easy: 0 => 1
* stage: Unreviewed => Accepted
Comment:
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
[https://docs.djangoproject.com/en/3.1/topics/db/queries/#making-queries
Blog - Entry], e.g.:
{{{
class Blog(models.Model):
# ...
pass
class Entry(models.Model):
blog = models.ForeignKey(Entry, on_delete=models.CASCADE)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32372#comment:2>
Comment (by Jack):
Replying to [comment:2 Mariusz Felisiak]:
Apologies, this is my first contribution so I'm still learning a lot. I've
followed the [https://docs.djangoproject.com/en/3.1/internals/contributing
/new-contributors/ Advice for new contributors] as well as
[https://docs.djangoproject.com/en/3.1/internals/contributing/writing-
documentation/ 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.
--
Ticket URL: <https://code.djangoproject.com/ticket/32372#comment:3>
Comment (by Tim Graham):
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/32372#comment:4>
* has_patch: 0 => 1
Comment:
Thanks, Tim!
PR was made here is the link: [https://github.com/django/django/pull/13926
PR #13926]
--
Ticket URL: <https://code.djangoproject.com/ticket/32372#comment:5>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"725c549ae7a34d83447201da7190f8d71c7fc2fc" 725c549]:
{{{
#!CommitTicketReference repository=""
revision="725c549ae7a34d83447201da7190f8d71c7fc2fc"
Fixed #32372 -- Made examples in related objects reference docs
consistent.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32372#comment:7>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"59c63c7f6b79ea9773aff34c53df3306e801800f" 59c63c7f]:
{{{
#!CommitTicketReference repository=""
revision="59c63c7f6b79ea9773aff34c53df3306e801800f"
[3.2.x] Fixed #32372 -- Made examples in related objects reference docs
consistent.
Backport of 725c549ae7a34d83447201da7190f8d71c7fc2fc from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32372#comment:6>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"cc5ee23f74b765f35b4ba05a122eef576cedbb3b" cc5ee23f]:
{{{
#!CommitTicketReference repository=""
revision="cc5ee23f74b765f35b4ba05a122eef576cedbb3b"
[3.1.x] Fixed #32372 -- Made examples in related objects reference docs
consistent.
Backport of 725c549ae7a34d83447201da7190f8d71c7fc2fc from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32372#comment:8>
Comment (by GitHub <noreply@…>):
In [changeset:"2b4b6c8af0aae8785bc1347cf1be2e8e70fd5ff3" 2b4b6c8a]:
{{{
#!CommitTicketReference repository=""
revision="2b4b6c8af0aae8785bc1347cf1be2e8e70fd5ff3"
Refs #32372 -- Updated manager name in related objects reference docs.
Follow up to 725c549ae7a34d83447201da7190f8d71c7fc2fc.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32372#comment:9>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"c708837a693f0554648b0442827a1e9f3ce67d3f" c708837a]:
{{{
#!CommitTicketReference repository=""
revision="c708837a693f0554648b0442827a1e9f3ce67d3f"
[3.2.x] Refs #32372 -- Updated manager name in related objects reference
docs.
Follow up to 725c549ae7a34d83447201da7190f8d71c7fc2fc.
Backport of 2b4b6c8af0aae8785bc1347cf1be2e8e70fd5ff3 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32372#comment:10>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"18adc89e50dca63b664a721ea9790279524b6db3" 18adc89e]:
{{{
#!CommitTicketReference repository=""
revision="18adc89e50dca63b664a721ea9790279524b6db3"
[3.1.x] Refs #32372 -- Updated manager name in related objects reference
docs.
Follow up to 725c549ae7a34d83447201da7190f8d71c7fc2fc.
Backport of 2b4b6c8af0aae8785bc1347cf1be2e8e70fd5ff3 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32372#comment:11>