Ticket #19555: 19555.diff

File 19555.diff, 1.3 KB (added by Tim Graham, 11 years ago)
  • docs/intro/tutorial01.txt

    diff --git a/docs/intro/tutorial01.txt b/docs/intro/tutorial01.txt
    index d24e19c..0f472f4 100644
    a b Save these changes and start a new Python interactive shell by running  
    647647    >>> Poll.objects.filter(question__startswith='What')
    648648    [<Poll: What's up?>]
    649649
    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    >>> Poll.objects.get(pub_date__year=timezone.now().year)
    652653    <Poll: What's up?>
    653654
    654655    # Request an ID that doesn't exist, this will raise an exception.
    Save these changes and start a new Python interactive shell by running  
    699700    # The API automatically follows relationships as far as you need.
    700701    # Use double underscores to separate relationships.
    701702    # 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)
     703    # Find all Choices for any poll whose pub_date is in this year.
     704    >>> Choice.objects.filter(poll__pub_date__year=timezone.now().year)
    704705    [<Choice: Not much>, <Choice: The sky>, <Choice: Just hacking again>]
    705706
    706707    # Let's delete one of the choices. Use delete() for that.
Back to Top