Ticket #5097: tutorial01.txt.diff

File tutorial01.txt.diff, 1.7 KB (added by Nicola Larosa <nico@…>, 17 years ago)
  • tutorial01.txt

     
    461461    >>> p.question
    462462    "What's up?"
    463463    >>> p.pub_date
    464     datetime.datetime(2005, 7, 15, 12, 00, 53)
     464    datetime.datetime(2007, 7, 15, 12, 00, 53)
    465465
    466466    # Change values by changing the attributes, then calling save().
    467     >>> p.pub_date = datetime(2005, 4, 1, 0, 0)
     467    >>> p.pub_date = datetime(2007, 4, 1, 0, 0)
    468468    >>> p.save()
    469469
    470470    # objects.all() displays all the polls in the database.
     
    537537    >>> Poll.objects.filter(question__startswith='What')
    538538    [<Poll: What's up?>]
    539539
    540     # Get the poll whose year is 2005. Of course, if you're going through this
     540    # Get the poll whose year is 2007. Of course, if you're going through this
    541541    # tutorial in another year, change as appropriate.
    542     >>> Poll.objects.get(pub_date__year=2005)
     542    >>> Poll.objects.get(pub_date__year=2007)
    543543    <Poll: What's up?>
    544544
    545545    >>> Poll.objects.get(id=2)
     
    580580
    581581    # The API automatically follows relationships as far as you need.
    582582    # Use double underscores to separate relationships.
    583     # This works as many levels deep as you want. There's no limit.
    584     # Find all Choices for any poll whose pub_date is in 2005.
    585     >>> Choice.objects.filter(poll__pub_date__year=2005)
     583    # This works as many levels deep as you want, there's no limit.
     584    # Find all Choices for any poll whose pub_date is in 2007.
     585    >>> Choice.objects.filter(poll__pub_date__year=2007)
    586586    [<Choice: Not much>, <Choice: The sky>, <Choice: Just hacking again>]
    587587
    588588    # Let's delete one of the choices. Use delete() for that.
Back to Top