Ticket #8406: model-repr.diff

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

Fixes all model repr's used in interactive session. (All I found by a visual grep, anyway)

  • docs/db-api.txt

     
    675675
    676676    # This list contains a Blog object.
    677677    >>> Blog.objects.filter(name__startswith='Beatles')
    678     [Beatles Blog]
     678    [<Blog: Beatles Blog>]
    679679
    680680    # This list contains a dictionary.
    681681    >>> Blog.objects.filter(name__startswith='Beatles').values()
     
    12471247Example::
    12481248
    12491249    >>> Blog.objects.in_bulk([1])
    1250     {1: Beatles Blog}
     1250    {1: <Blog: Beatles Blog>}
    12511251    >>> Blog.objects.in_bulk([1, 2])
    1252     {1: Beatles Blog, 2: Cheddar Talk}
     1252    {1: <Blog: Beatles Blog>, 2: <Blog: Cheddar Talk>}
    12531253    >>> Blog.objects.in_bulk([])
    12541254    {}
    12551255
  • docs/overview.txt

     
    7474
    7575    # Now the new reporter is in the database.
    7676    >>> Reporter.objects.all()
    77     [John Smith]
     77    [<Reporter: John Smith>]
    7878
    7979    # Fields are represented as attributes on the Python object.
    8080    >>> r.full_name
     
    8282
    8383    # Django provides a rich database lookup API.
    8484    >>> Reporter.objects.get(id=1)
    85     John Smith
     85    <Reporter: John Smith>
    8686    >>> Reporter.objects.get(full_name__startswith='John')
    87     John Smith
     87    <Reporter: John Smith>
    8888    >>> Reporter.objects.get(full_name__contains='mith')
    89     John Smith
     89    <Reporter: John Smith>
    9090    >>> Reporter.objects.get(id=2)
    9191    Traceback (most recent call last):
    9292        ...
    93     DoesNotExist: Reporter does not exist for {'id__exact': 2}
     93    DoesNotExist: Reporter matching query does not exist.
    9494
    9595    # Create an article.
    9696    >>> from datetime import datetime
     
    100100
    101101    # Now the article is in the database.
    102102    >>> Article.objects.all()
    103     [Django is cool]
     103    [<Article: Django is cool>]
    104104
    105105    # Article objects get API access to related Reporter objects.
    106106    >>> r = a.reporter
     
    109109
    110110    # And vice versa: Reporter objects get API access to Article objects.
    111111    >>> r.article_set.all()
    112     [Django is cool]
     112    [<Article: Django is cool>]
    113113
    114114    # The API follows relationships as far as you need, performing efficient
    115115    # JOINs for you behind the scenes.
    116116    # This finds all articles by a reporter whose name starts with "John".
    117117    >>> Article.objects.filter(reporter__full_name__startswith="John")
    118     [Django is cool]
     118    [<Article: Django is cool>]
    119119
    120120    # Change an object by altering its attributes and calling save().
    121121    >>> r.full_name = 'Billy Goat'
Back to Top