Opened 6 years ago
Last modified 6 years ago
#29591 closed Bug
ManyToManyField examples are confused about how many Publication objects there are — at Initial Version
Reported by: | Marnanel Thurman | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 2.0 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In https://docs.djangoproject.com/en/2.0/topics/db/examples/many_to_many/ , the text says there are two Publication objects ("a couple" and "both"), but the code example creates three, and uses three.
Create a couple of Publications:
p1 = Publication(title='The Python Journal')
p1.save()
p2 = Publication(title='Science News')
p2.save()
p3 = Publication(title='Science Weekly')
p3.save()
[...]
Create another Article, and set it to appear in both Publications:
a2 = Article(headline='NASA uses Python')
a2.save()
a2.publications.add(p1, p2)
a2.publications.add(p3)