From ce6f058bbb79e9b9eae198b066c6db6eb0683a21 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Thu, 18 May 2006 12:41:24 +0000 Subject: [PATCH] Fixed #1724 -- updated the output from the shell commands to match what we now produce. git-svn-id: http://code.djangoproject.com/svn/django/trunk@2937 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/tutorial01.txt | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/tutorial01.txt b/docs/tutorial01.txt index 03d4eac635..c353e1ab4b 100644 --- a/docs/tutorial01.txt +++ b/docs/tutorial01.txt @@ -445,13 +445,13 @@ Once you're in the shell, explore the database API:: # objects.all() displays all the polls in the database. >>> Poll.objects.all() - [] + [] -Wait a minute. ```` is, utterly, an unhelpful representation of -this object. Let's fix that by editing the polls model -(in the ``polls/models.py`` file) and adding a ``__str__()`` method to -both ``Poll`` and ``Choice``:: +Wait a minute. ```` is, utterly, an unhelpful +representation of this object. Let's fix that by editing the polls model (in +the ``polls/models.py`` file) and adding a ``__str__()`` method to both +``Poll`` and ``Choice``:: class Poll(models.Model): # ... @@ -487,30 +487,30 @@ Let's jump back into the Python interactive shell by running # Make sure our __str__() addition worked. >>> Poll.objects.all() - [What's up?] + [] # Django provides a rich database lookup API that's entirely driven by # keyword arguments. >>> Poll.objects.filter(id=1) - [What's up?] + [] >>> Poll.objects.filter(question__startswith='What') - [What's up?] + [] # Get the poll whose year is 2005. Of course, if you're going through this # tutorial in another year, change as appropriate. >>> Poll.objects.get(pub_date__year=2005) - What's up? + >>> Poll.objects.get(id=2) Traceback (most recent call last): ... - DoesNotExist: Poll does not exist for {'id': 2} + DoesNotExist: Poll matching query does not exist. # Lookup by a primary key is the most common case, so Django provides a # shortcut for primary-key exact lookups. # The following is identical to Poll.objects.get(id=1). >>> Poll.objects.get(pk=1) - What's up? + # Make sure our custom method worked. >>> p = Poll.objects.get(pk=1) @@ -522,18 +522,18 @@ Let's jump back into the Python interactive shell by running # of available choices and returns the new Choice object. >>> p = Poll.objects.get(pk=1) >>> p.choice_set.create(choice='Not much', votes=0) - Not much + >>> p.choice_set.create(choice='The sky', votes=0) - The sky + >>> c = p.choice_set.create(choice='Just hacking again', votes=0) # Choice objects have API access to their related Poll objects. >>> c.poll - What's up? + # And vice versa: Poll objects get access to Choice objects. >>> p.choice_set.all() - [Not much, The sky, Just hacking again] + [, , ] >>> p.choice_set.count() 3 @@ -542,7 +542,7 @@ Let's jump back into the Python interactive shell by running # This works as many levels deep as you want. There's no limit. # Find all Choices for any poll whose pub_date is in 2005. >>> Choice.objects.filter(poll__pub_date__year=2005) - [Not much, The sky, Just hacking again] + [, , ] # Let's delete one of the choices. Use delete() for that. >>> c = p.choice_set.filter(choice__startswith='Just hacking')