Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.1.X] Fixed #12114 -- Clarified the existence of the reverse relati…

…on _set in the tutorial. Thanks to panfist for the suggestion, and dwillis for the patch.

Backport of r12711 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12714 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit fdbf6c881b0a2382a69ca137520170531b08dfee 1 parent ec6f705
@freakboy3742 freakboy3742 authored
Showing with 12 additions and 3 deletions.
  1. +12 −3 docs/intro/tutorial01.txt
View
15 docs/intro/tutorial01.txt
@@ -650,8 +650,16 @@ Save these changes and start a new Python interactive shell by running
# Give the Poll a couple of Choices. The create call constructs a new
# choice object, does the INSERT statement, adds the choice to the set
- # of available choices and returns the new Choice object.
+ # of available choices and returns the new Choice object. Django creates
+ # a set to hold the "other side" of a ForeignKey relation
+ # (e.g. a poll's choices) which can be accessed via the API.
>>> p = Poll.objects.get(pk=1)
+
+ # Display any choices from the related object set -- none so far.
+ >>> p.choice_set.all()
+ []
+
+ # Create three choices.
>>> p.choice_set.create(choice='Not much', votes=0)
<Choice: Not much>
>>> p.choice_set.create(choice='The sky', votes=0)
@@ -679,8 +687,9 @@ Save these changes and start a new Python interactive shell by running
>>> c = p.choice_set.filter(choice__startswith='Just hacking')
>>> c.delete()
-For full details on the database API, see our :ref:`Database API reference
-<topics-db-queries>`.
+For more information on model relations, see :ref:`Accessing related objects
+<ref-models-relations>`. For full details on the database API, see our
+:ref:`Database API reference <topics-db-queries>`.
When you're comfortable with the API, read :ref:`part 2 of this tutorial
<intro-tutorial02>` to get Django's automatic admin working.
Please sign in to comment.
Something went wrong with that request. Please try again.