Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.5.x] Fixed #19555 - Removed '2012' from tutorial 1.

Thanks rodrigorosa.lg and others for the report.

Backport of 99315f7 from master
  • Loading branch information...
commit c95ae7729f713a300e67bf30e9506ba78919113a 1 parent 78739fa
Tim Graham authored January 08, 2013

Showing 1 changed file with 7 additions and 4 deletions. Show diff stats Hide diff stats

  1. 11  docs/intro/tutorial01.txt
11  docs/intro/tutorial01.txt
@@ -647,8 +647,10 @@ Save these changes and start a new Python interactive shell by running
647 647
     >>> Poll.objects.filter(question__startswith='What')
648 648
     [<Poll: What's up?>]
649 649
 
650  
-    # Get the poll whose year is 2012.
651  
-    >>> Poll.objects.get(pub_date__year=2012)
  650
+    # Get the poll that was published this year.
  651
+    >>> from django.utils import timezone
  652
+    >>> current_year = timezone.now().year
  653
+    >>> Poll.objects.get(pub_date__year=current_year)
652 654
     <Poll: What's up?>
653 655
 
654 656
     # Request an ID that doesn't exist, this will raise an exception.
@@ -699,8 +701,9 @@ Save these changes and start a new Python interactive shell by running
699 701
     # The API automatically follows relationships as far as you need.
700 702
     # Use double underscores to separate relationships.
701 703
     # This works as many levels deep as you want; there's no limit.
702  
-    # Find all Choices for any poll whose pub_date is in 2012.
703  
-    >>> Choice.objects.filter(poll__pub_date__year=2012)
  704
+    # Find all Choices for any poll whose pub_date is in this year
  705
+    # (reusing the 'current_year' variable we created above).
  706
+    >>> Choice.objects.filter(poll__pub_date__year=current_year)
704 707
     [<Choice: Not much>, <Choice: The sky>, <Choice: Just hacking again>]
705 708
 
706 709
     # Let's delete one of the choices. Use delete() for that.

0 notes on commit c95ae77

Please sign in to comment.
Something went wrong with that request. Please try again.