Code

Opened 9 months ago

Closed 9 months ago

#21246 closed Cleanup/optimization (invalid)

Issues with "Models"-Documentation

Reported by: david-schultz@… Owned by: nobody
Component: Documentation Version: 1.5
Severity: Normal Keywords: Documentation Models Minor
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Hello guys,
reading that file (https://docs.djangoproject.com/en/1.5/topics/db/models/) , I found two things that probably should be replaced:


1.

Section "Many-to-one relationships" has a paragraph:
"You can also create recursive relationships (an object with a many-to-one relationship to itself) and relationships to models not yet defined; see the model field reference for details." (Bold by me.)

To me, the term "object" is confusing at this point, as I understand it as being an instance of the class, whereas you are clearly talking about a relationship between different instances of the same class. However, you use this terminology at other places as well, so I am not quite sure about this, since I also am rather new to Python and especially Django.


2.

Second Code example of section "Extra fields on many-to-many relationships" ends with:

>>> m2 = Membership.objects.create(person=paul, group=beatles,
...     date_joined=date(1960, 8, 1),
...     invite_reason= "Wanted to form a band.")
>>> beatles.members.all()
[<Person: Ringo Starr>, <Person: Paul McCartney>]

I'm sure you forgot a m2.save() before calling beatles.members.all().

Best regards
David

Attachments (0)

Change History (1)

comment:1 Changed 9 months ago by timo

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

Thanks for your feedback, but I think both of these points are ok as-is.

  1. I think the usage of this terminology is ok. As you've noted it's used elsewhere in the doc.
  1. The code is correct as-is. When you use create(), the relationship is immediately created in the database -- no need to cause save().

If you find any other issues, please don't hesitate to let us know.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.