Code

Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#13538 closed (fixed)

Clarifications for http://docs.djangoproject.com/en/dev/topics/db/queries/

Reported by: yipengh87@… Owned by: dwillis
Component: Documentation Version: 1.1
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by kmtracey)

The referenced class uses a capital E....
class Entry(models.Model)

But under "Saving ForeignKey and ManyToManyField fields",
a small E is used...

>>> entry.blog = cheese_blog
>>> entry.save()

Before the above line can be executed, there is also a missing import statement...

>>> from mysite.blog.models import *

Attachments (2)

13538.diff (1.5 KB) - added by dwillis 4 years ago.
13538.2.diff (1.3 KB) - added by timo 4 years ago.
updating existing patch to fix syntax highlighting

Download all attachments as: .zip

Change History (11)

comment:1 Changed 4 years ago by kmtracey

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from Mistakes in http://docs.djangoproject.com/en/dev/topics/db/queries/ to Clarificications for http://docs.djangoproject.com/en/dev/topics/db/queries/
  • Triage Stage changed from Unreviewed to Accepted

(Fixed description formatting. Please use preview.)

The text in question is here: http://docs.djangoproject.com/en/dev/topics/db/queries/#saving-foreignkey-and-manytomanyfield-fields

The Entry/entry difference is not an error in the documentation. The lowercase-e entry is assumed to be an instance of the Entry class. The previous section on saving changes to an object makes that clear by noting what b5 is before using it in the example code, it would probably make sense to avoid confusion and note something similar before entry is used.

The page does show an import for Blog, but not the other models used. In reading through the text, though, it's clear that the Blog import is done to show an example of how to do it; the remaining text assumes corresponding imports have been done for the other models used. It might not hurt to point that out in the text.

comment:2 Changed 4 years ago by dwillis

  • Owner changed from nobody to dwillis
  • Status changed from new to assigned

Changed 4 years ago by dwillis

comment:3 Changed 4 years ago by dwillis

  • Has patch set
  • milestone set to 1.3

Added patch with some clarifications and additional imports.

Changed 4 years ago by timo

updating existing patch to fix syntax highlighting

comment:4 Changed 4 years ago by timo

  • Triage Stage changed from Accepted to Ready for checkin

comment:5 Changed 4 years ago by gabrielhurley

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [14070]) Fixes #13538 -- Clarified query examples with more explicit import statements and model vs. instance differentiation. Thanks to yipengh87@… and kmtracey for the report, and timo for the patch.

comment:6 Changed 4 years ago by gabrielhurley

(In [14073]) [1.2.X] Fixed #13538 -- Clarified query examples with more explicit import statements and model vs. instance differentiation. Thanks to yipengh87 and kmtracey for the report, and timo for the patch.

Backport of [14070] from trunk.

comment:7 Changed 4 years ago by DrMeers

Shouldn't we be avoiding encouraging the use of project names such as 'mysite' in imports? cf. #14255

comment:8 Changed 4 years ago by gabrielhurley

  • Summary changed from Clarificications for http://docs.djangoproject.com/en/dev/topics/db/queries/ to Clarifications for http://docs.djangoproject.com/en/dev/topics/db/queries/

Ha. True enough. Picked up the patch for this before I saw your commit on that one. I'll fix it momentarily.

comment:9 Changed 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

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.