Ticket #8406: model-repr-r8629.diff

File model-repr-r8629.diff, 2.6 KB (added by arien, 16 years ago)

patch updated for documentation refactor

  • docs/intro/overview.txt

     
    7777
    7878    # Now the new reporter is in the database.
    7979    >>> Reporter.objects.all()
    80     [John Smith]
     80    [<Reporter: John Smith>]
    8181
    8282    # Fields are represented as attributes on the Python object.
    8383    >>> r.full_name
     
    8585
    8686    # Django provides a rich database lookup API.
    8787    >>> Reporter.objects.get(id=1)
    88     John Smith
     88    <Reporter: John Smith>
    8989    >>> Reporter.objects.get(full_name__startswith='John')
    90     John Smith
     90    <Reporter: John Smith>
    9191    >>> Reporter.objects.get(full_name__contains='mith')
    92     John Smith
     92    <Reporter: John Smith>
    9393    >>> Reporter.objects.get(id=2)
    9494    Traceback (most recent call last):
    9595        ...
    96     DoesNotExist: Reporter does not exist for {'id__exact': 2}
     96    DoesNotExist: Reporter matching query does not exist.
    9797
    9898    # Create an article.
    9999    >>> from datetime import datetime
     
    103103
    104104    # Now the article is in the database.
    105105    >>> Article.objects.all()
    106     [Django is cool]
     106    [<Article: Django is cool>]
    107107
    108108    # Article objects get API access to related Reporter objects.
    109109    >>> r = a.reporter
     
    112112
    113113    # And vice versa: Reporter objects get API access to Article objects.
    114114    >>> r.article_set.all()
    115     [Django is cool]
     115    [<Article: Django is cool>]
    116116
    117117    # The API follows relationships as far as you need, performing efficient
    118118    # JOINs for you behind the scenes.
    119119    # This finds all articles by a reporter whose name starts with "John".
    120120    >>> Article.objects.filter(reporter__full_name__startswith="John")
    121     [Django is cool]
     121    [<Article: Django is cool>]
    122122
    123123    # Change an object by altering its attributes and calling save().
    124124    >>> r.full_name = 'Billy Goat'
  • docs/ref/models/querysets.txt

     
    190190
    191191    # This list contains a Blog object.
    192192    >>> Blog.objects.filter(name__startswith='Beatles')
    193     [Beatles Blog]
     193    [<Blog: Beatles Blog>]
    194194
    195195    # This list contains a dictionary.
    196196    >>> Blog.objects.filter(name__startswith='Beatles').values()
     
    650650Example::
    651651
    652652    >>> Blog.objects.in_bulk([1])
    653     {1: Beatles Blog}
     653    {1: <Blog: Beatles Blog>}
    654654    >>> Blog.objects.in_bulk([1, 2])
    655     {1: Beatles Blog, 2: Cheddar Talk}
     655    {1: <Blog: Beatles Blog>, 2: <Blog: Cheddar Talk>}
    656656    >>> Blog.objects.in_bulk([])
    657657    {}
    658658
Back to Top