Skip to content

Commit

Permalink
Fixed #19555 - Removed '2012' from tutorial 1.
Browse files Browse the repository at this point in the history
Thanks rodrigorosa.lg and others for the report.
  • Loading branch information
timgraham committed Jan 8, 2013
1 parent f58efd0 commit 99315f7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions docs/intro/tutorial01.txt
Expand Up @@ -647,8 +647,10 @@ Save these changes and start a new Python interactive shell by running
>>> Poll.objects.filter(question__startswith='What') >>> Poll.objects.filter(question__startswith='What')
[<Poll: What's up?>] [<Poll: What's up?>]


# Get the poll whose year is 2012. # Get the poll that was published this year.
>>> Poll.objects.get(pub_date__year=2012) >>> from django.utils import timezone
>>> current_year = timezone.now().year
>>> Poll.objects.get(pub_date__year=current_year)
<Poll: What's up?> <Poll: What's up?>


# Request an ID that doesn't exist, this will raise an exception. # Request an ID that doesn't exist, this will raise an exception.
Expand Down Expand Up @@ -699,8 +701,9 @@ Save these changes and start a new Python interactive shell by running
# The API automatically follows relationships as far as you need. # The API automatically follows relationships as far as you need.
# Use double underscores to separate relationships. # Use double underscores to separate relationships.
# This works as many levels deep as you want; there's no limit. # This works as many levels deep as you want; there's no limit.
# Find all Choices for any poll whose pub_date is in 2012. # Find all Choices for any poll whose pub_date is in this year
>>> Choice.objects.filter(poll__pub_date__year=2012) # (reusing the 'current_year' variable we created above).
>>> Choice.objects.filter(poll__pub_date__year=current_year)
[<Choice: Not much>, <Choice: The sky>, <Choice: Just hacking again>] [<Choice: Not much>, <Choice: The sky>, <Choice: Just hacking again>]


# Let's delete one of the choices. Use delete() for that. # Let's delete one of the choices. Use delete() for that.
Expand Down

0 comments on commit 99315f7

Please sign in to comment.