Django

Code

Changeset 2195

Show
Ignore:
Timestamp:
01/30/06 19:08:02 (3 years ago)
Author:
adrian
Message:

magic-removal: Changed syntax in unit tests -- hopefully for the last time.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/magic-removal/tests/modeltests/basic/models.py

    r2190 r2195  
    1414 
    1515# No articles are in the system yet. 
    16 >>> list(Article.objects.all()
     16>>> Article.objects.all(
    1717[] 
    1818 
     
    4141# is represented by "<Article object>", because we haven't given the Article 
    4242# model a __repr__() method. 
    43 >>> list(Article.objects.all()
     43>>> Article.objects.all(
    4444[<Article object>] 
    4545 
     
    6363<Article object> 
    6464 
    65 >>> list(Article.objects.filter(pub_date__year=2005)
     65>>> Article.objects.filter(pub_date__year=2005
    6666[<Article object>] 
    67 >>> list(Article.objects.filter(pub_date__year=2004)
     67>>> Article.objects.filter(pub_date__year=2004
    6868[] 
    69 >>> list(Article.objects.filter(pub_date__year=2005, pub_date__month=7)
     69>>> Article.objects.filter(pub_date__year=2005, pub_date__month=7
    7070[<Article object>] 
    7171 
  • django/branches/magic-removal/tests/modeltests/custom_columns/models.py

    r2190 r2195  
    24241 
    2525 
    26 >>> list(Person.objects.all()
     26>>> Person.objects.all(
    2727[John Smith] 
    2828 
    29 >>> list(Person.objects.filter(first_name__exact='John')
     29>>> Person.objects.filter(first_name__exact='John'
    3030[John Smith] 
    3131 
     
    3333John Smith 
    3434 
    35 >>> list(Person.objects.filter(firstname__exact='John')
     35>>> Person.objects.filter(firstname__exact='John'
    3636Traceback (most recent call last): 
    3737    ... 
  • django/branches/magic-removal/tests/modeltests/custom_managers/models.py

    r2169 r2195  
    99class PersonManager(models.Manager): 
    1010    def get_fun_people(self): 
    11         return list(self.filter(fun=True)
     11        return self.filter(fun=True
    1212 
    1313class Person(models.Model): 
     
    6969AttributeError: type object 'Book' has no attribute 'objects' 
    7070 
    71 >>> list(Book.published_objects
     71>>> Book.published_objects.all(
    7272[How to program] 
    7373 
     
    7676>>> c2 = Car(name='Neon', mileage=31, top_speed=100) 
    7777>>> c2.save() 
    78 >>> list(Car.cars.order_by('name')
     78>>> Car.cars.order_by('name'
    7979[Corvette, Neon] 
    80 >>> list(Car.fast_cars
     80>>> Car.fast_cars.all(
    8181[Corvette] 
    8282 
    8383# Each model class gets a "_default_manager" attribute, which is a reference 
    8484# to the first manager defined in the class. In this case, it's "cars". 
    85 >>> list(Car._default_manager.order_by('name')
     85>>> Car._default_manager.order_by('name'
    8686[Corvette, Neon] 
    8787""" 
  • django/branches/magic-removal/tests/modeltests/custom_methods/models.py

    r2125 r2195  
    1919 
    2020    def get_articles_from_same_day_1(self): 
    21         return Article.objects.get_list(id__ne=self.id, pub_date__exact=self.pub_date) 
     21        return Article.objects.filter(id__ne=self.id, pub_date__exact=self.pub_date) 
    2222 
    2323    def get_articles_from_same_day_2(self): 
  • django/branches/magic-removal/tests/modeltests/custom_pk/models.py

    r2190 r2195  
    3030>>> dan = Employee(employee_code='ABC123', first_name='Dan', last_name='Jones') 
    3131>>> dan.save() 
    32 >>> list(Employee.objects.all()
     32>>> Employee.objects.all(
    3333[Dan Jones] 
    3434 
    3535>>> fran = Employee(employee_code='XYZ456', first_name='Fran', last_name='Bones') 
    3636>>> fran.save() 
    37 >>> list(Employee.objects.all()
     37>>> Employee.objects.all(
    3838[Fran Bones, Dan Jones] 
    3939 
     
    5555>>> fran.last_name = 'Jones' 
    5656>>> fran.save() 
    57 >>> list(Employee.objects.filter(last_name__exact='Jones')
     57>>> Employee.objects.filter(last_name__exact='Jones'
    5858[Dan Jones, Fran Jones] 
    5959>>> Employee.objects.in_bulk(['ABC123', 'XYZ456']) 
     
    6464>>> b.set_employees([dan.employee_code, fran.employee_code]) 
    6565True 
    66 >>> list(b.employee_set
     66>>> b.employee_set.all(
    6767[Dan Jones, Fran Jones] 
    68 >>> list(fran.business_set
     68>>> fran.business_set.all(
    6969[Sears] 
    7070>>> Business.objects.in_bulk(['Sears']) 
    7171{'Sears': Sears} 
    7272 
    73 >>> list(Business.objects.filter(name__exact='Sears')
     73>>> Business.objects.filter(name__exact='Sears'
    7474[Sears] 
    75 >>> list(Business.objects.filter(pk='Sears')
     75>>> Business.objects.filter(pk='Sears'
    7676[Sears] 
    7777 
    7878# Queries across tables, involving primary key 
    79 >>> list(Employee.objects.filter(business__name__exact='Sears')
     79>>> Employee.objects.filter(business__name__exact='Sears'
    8080[Dan Jones, Fran Jones] 
    81 >>> list(Employee.objects.filter(business__pk='Sears')
     81>>> Employee.objects.filter(business__pk='Sears'
    8282[Dan Jones, Fran Jones] 
    8383 
    84 >>> list(Business.objects.filter(employees__employee_code__exact='ABC123')
     84>>> Business.objects.filter(employees__employee_code__exact='ABC123'
    8585[Sears] 
    86 >>> list(Business.objects.filter(employees__pk='ABC123')
     86>>> Business.objects.filter(employees__pk='ABC123'
    8787[Sears] 
    88 >>> list(Business.objects.filter(employees__first_name__startswith='Fran')
     88>>> Business.objects.filter(employees__first_name__startswith='Fran'
    8989[Sears] 
    9090 
  • django/branches/magic-removal/tests/modeltests/lookup/models.py

    r2181 r2195  
    8585# values() returns a list of dictionaries instead of object instances -- and 
    8686# you can specify which fields you want to retrieve. 
    87 >>> list(Article.objects.values('headline')
     87>>> Article.objects.values('headline'
    8888[{'headline': 'Article 5'}, {'headline': 'Article 6'}, {'headline': 'Article 4'}, {'headline': 'Article 2'}, {'headline': 'Article 3'}, {'headline': 'Article 7'}, {'headline': 'Article 1'}] 
    89 >>> list(Article.objects.filter(pub_date__exact=datetime(2005, 7, 27)).values('id')
     89>>> Article.objects.filter(pub_date__exact=datetime(2005, 7, 27)).values('id'
    9090[{'id': 2}, {'id': 3}, {'id': 7}] 
    9191>>> list(Article.objects.values('id', 'headline')) == [{'id': 5, 'headline': 'Article 5'}, {'id': 6, 'headline': 'Article 6'}, {'id': 4, 'headline': 'Article 4'}, {'id': 2, 'headline': 'Article 2'}, {'id': 3, 'headline': 'Article 3'}, {'id': 7, 'headline': 'Article 7'}, {'id': 1, 'headline': 'Article 1'}] 
     
    142142>>> a8 = Article(headline='Article_ with underscore', pub_date=datetime(2005, 11, 20)) 
    143143>>> a8.save() 
    144 >>> list(Article.objects.filter(headline__startswith='Article')
     144>>> Article.objects.filter(headline__startswith='Article'
    145145[Article_ with underscore, Article 5, Article 6, Article 4, Article 2, Article 3, Article 7, Article 1] 
    146 >>> list(Article.objects.filter(headline__startswith='Article_')
     146>>> Article.objects.filter(headline__startswith='Article_'
    147147[Article_ with underscore] 
    148148>>> a9 = Article(headline='Article% with percent sign', pub_date=datetime(2005, 11, 21)) 
    149149>>> a9.save() 
    150 >>> list(Article.objects.filter(headline__startswith='Article')
     150>>> Article.objects.filter(headline__startswith='Article'
    151151[Article% with percent sign, Article_ with underscore, Article 5, Article 6, Article 4, Article 2, Article 3, Article 7, Article 1] 
    152 >>> list(Article.objects.filter(headline__startswith='Article%')
     152>>> Article.objects.filter(headline__startswith='Article%'
    153153[Article% with percent sign] 
    154154""" 
  • django/branches/magic-removal/tests/modeltests/m2m_intermediary/models.py

    r2157 r2195  
    5454 
    5555# Play around with the API. 
    56 >>> list(a.writer_set.order_by('-position').extra(select_related=True)
     56>>> a.writer_set.select_related().order_by('-position'
    5757[John Smith (Main writer), Jane Doe (Contributor)] 
    5858>>> w1.reporter 
     
    6464>>> w2.article 
    6565This is a test 
    66 >>> list(r1.writer_set
     66>>> r1.writer_set.all(
    6767[John Smith (Main writer)] 
    6868""" 
  • django/branches/magic-removal/tests/modeltests/m2m_multiple/models.py

    r2157 r2195  
    6464# would cause a conflict because the "primary_categories" and 
    6565# "secondary_categories" fields both relate to Category. 
    66 >>> list(a1.primary_category_set
     66>>> a1.primary_category_set.all(
    6767[Crime, News] 
    6868 
    6969# Ditto for the "primary_category" here. 
    70 >>> list(a2.primary_category_set
     70>>> a2.primary_category_set.all(
    7171[News, Sports] 
    7272 
    7373# Ditto for the "secondary_category" here. 
    74 >>> list(a1.secondary_category_set) 
    75 [Life] 
    76  
    77 # Ditto for the "secondary_category" here. 
    78 >>> list(a2.secondary_category) 
     74>>> a1.secondary_category_set.all() 
    7975[Life] 
    8076 
    8177 
    82 >>> list(c1.primary_article_set
     78>>> c1.primary_article_set.all(
    8379[Area man runs] 
    84 >>> list(c1.secondary_article_set
     80>>> c1.secondary_article_set.all(
    8581[] 
    86 >>> list(c2.primary_article_set
     82>>> c2.primary_article_set.all(
    8783[Area man steals, Area man runs] 
    88 >>> list(c2.secondary_article_set
     84>>> c2.secondary_article_set.all(
    8985[] 
    90 >>> list(c3.primary_article_set
     86>>> c3.primary_article_set.all(
    9187[Area man steals] 
    92 >>> list(c3.secondary_article_set
     88>>> c3.secondary_article_set.all(
    9389[] 
    94 >>> list(c4.primary_article_set
     90>>> c4.primary_article_set.all(
    9591[] 
    96 >>> list(c4.secondary_article_set
     92>>> c4.secondary_article_set.all(
    9793[Area man steals, Area man runs] 
    9894""" 
  • django/branches/magic-removal/tests/modeltests/m2o_recursive2/models.py

    r2157 r2195  
    3333>>> kid.father 
    3434John Smith Senior 
    35 >>> list(dad.fathers_child_set
     35>>> dad.fathers_child_set.all(
    3636[John Smith Junior] 
    37 >>> list(mom.mothers_child_set
     37>>> mom.mothers_child_set.all(
    3838[John Smith Junior] 
    39 >>> list(kid.mothers_child_set
     39>>> kid.mothers_child_set.all(
    4040[] 
    41 >>> list(kid.fathers_child_set
     41>>> kid.fathers_child_set.all(
    4242[] 
    4343""" 
  • django/branches/magic-removal/tests/modeltests/m2o_recursive/models.py

    r2157 r2195  
    2727>>> c.save() 
    2828 
    29 >>> list(r.child_set
     29>>> r.child_set.all(
    3030[Child category] 
    3131>>> r.child_set.get(name__startswith='Child') 
     
    3636DoesNotExist 
    3737 
    38 >>> list(c.child_set
     38>>> c.child_set.all(
    3939[] 
    4040>>> c.parent 
  • django/branches/magic-removal/tests/modeltests/manipulators/models.py

    r2190 r2195  
    3333 
    3434# Verify it worked. 
    35 >>> list(Musician.objects.all()
     35>>> Musician.objects.all(
    3636[Ella Fitzgerald] 
    3737>>> [m1] == list(Musician.objects.all()) 
     
    6767 
    6868# Verify it worked. 
    69 >>> list(Album.objects.all()
     69>>> Album.objects.all(
    7070[Ella and Basie] 
    7171>>> Album.objects.get().musician 
     
    8080 
    8181# Verify it worked. 
    82 >>> list(Album.objects.order_by('name')
     82>>> Album.objects.order_by('name'
    8383[Ella and Basie, Ultimate Ella] 
    8484>>> a2 = Album.objects.get(pk=2) 
  • django/branches/magic-removal/tests/modeltests/many_to_many/models.py

    r2190 r2195  
    5757 
    5858# Article objects have access to their related Publication objects. 
    59 >>> list(a1.publication_set
     59>>> a1.publication_set.all(
    6060[The Python Journal] 
    61 >>> list(a2.publication_set
     61>>> a2.publication_set.all(
    6262[The Python Journal, Science News, Science Weekly] 
    6363 
    6464# Publication objects have access to their related Article objects. 
    65 >>> list(p2.article_set
     65>>> p2.article_set.all(
    6666[NASA uses Python] 
    67 >>> list(p1.article_set.order_by('headline')
     67>>> p1.article_set.order_by('headline'
    6868[Django lets you build Web apps easily, NASA uses Python] 
    6969 
    7070# We can perform kwarg queries across m2m relationships 
    71 >>> list(Article.objects.filter(publications__id__exact=1)
     71>>> Article.objects.filter(publications__id__exact=1
    7272[Django lets you build Web apps easily, NASA uses Python] 
    73 >>> list(Article.objects.filter(publications__pk=1)
     73>>> Article.objects.filter(publications__pk=1
    7474[Django lets you build Web apps easily, NASA uses Python] 
    7575 
    76 >>> list(Article.objects.filter(publications__title__startswith="Science")
     76>>> Article.objects.filter(publications__title__startswith="Science"
    7777[NASA uses Python, NASA uses Python] 
    7878 
    79 >>> list(Article.objects.filter(publications__title__startswith="Science").distinct()
     79>>> Article.objects.filter(publications__title__startswith="Science").distinct(
    8080[NASA uses Python] 
    8181 
    8282# Reverse m2m queries (i.e., start at the table that doesn't have a ManyToManyField) 
    83 >>> list(Publication.objects.filter(id__exact=1)
     83>>> Publication.objects.filter(id__exact=1
    8484[The Python Journal] 
    85 >>> list(Publication.objects.filter(pk=1)
     85>>> Publication.objects.filter(pk=1
    8686[The Python Journal] 
    8787 
    88 >>> list(Publication.objects.filter(article__headline__startswith="NASA")
     88>>> Publication.objects.filter(article__headline__startswith="NASA"
    8989[The Python Journal, Science News, Science Weekly] 
    9090 
    91 >>> list(Publication.objects.filter(article__id__exact=1)
     91>>> Publication.objects.filter(article__id__exact=1
    9292[The Python Journal] 
    9393 
    94 >>> list(Publication.objects.filter(article__pk=1)
     94>>> Publication.objects.filter(article__pk=1
    9595[The Python Journal] 
    9696 
    9797# If we delete a Publication, its Articles won't be able to access it. 
    9898>>> p1.delete() 
    99 >>> list(Publication.objects.all()
     99>>> Publication.objects.all(
    100100[Science News, Science Weekly] 
    101101>>> a1 = Article.objects.get(pk=1) 
    102 >>> list(a1.publication_set
     102>>> a1.publication_set.all(
    103103[] 
    104104 
    105105# If we delete an Article, its Publications won't be able to access it. 
    106106>>> a2.delete() 
    107 >>> list(Article.objects.all()
     107>>> Article.objects.all(
    108108[Django lets you build Web apps easily] 
    109 >>> list(p1.article_set.order_by('headline')
     109>>> p1.article_set.order_by('headline'
    110110[Django lets you build Web apps easily] 
    111111""" 
  • django/branches/magic-removal/tests/modeltests/many_to_one/models.py

    r2185 r2195  
    6060 
    6161# Reporter objects have access to their related Article objects. 
    62 >>> list(r.article_set.order_by('pub_date')
     62>>> r.article_set.order_by('pub_date'
    6363[This is a test, John's second story] 
    6464 
    65 >>> list(r.article_set.filter(headline__startswith='This')
     65>>> r.article_set.filter(headline__startswith='This'
    6666This is a test 
    6767 
     
    7373 
    7474# Get articles by id 
    75 >>> list(Article.objects.filter(id__exact=1)
     75>>> Article.objects.filter(id__exact=1
    7676[This is a test] 
    77 >>> list(Article.objects.filter(pk=1)
     77>>> Article.objects.filter(pk=1
    7878[This is a test] 
    7979 
    8080# Query on an article property 
    81 >>> list(Article.objects.filter(headline__startswith='This')
     81>>> Article.objects.filter(headline__startswith='This'
    8282[This is a test] 
    8383 
     
    8686# This works as many levels deep as you want. There's no limit. 
    8787# Find all Articles for any Reporter whose first name is "John". 
    88 >>> list(Article.objects.filter(reporter__first_name__exact='John').order_by('pub_date')
     88>>> Article.objects.filter(reporter__first_name__exact='John').order_by('pub_date'
    8989[This is a test, John's second story] 
    9090 
    9191# Query twice over the related field. 
    92 >>> list(Article.objects.filter(reporter__first_name__exact='John', reporter__last_name__exact='Smith')
     92>>> Article.objects.filter(reporter__first_name__exact='John', reporter__last_name__exact='Smith'
    9393[This is a test, John's second story] 
    9494 
     
    100100 
    101101# The automatically joined table has a predictable name. 
    102 >>> list(Article.objects.filter(reporter__first_name__exact='John').extra(where=["many_to_one_article__reporter.last_name='Smith'"])
     102>>> Article.objects.filter(reporter__first_name__exact='John').extra(where=["many_to_one_article__reporter.last_name='Smith'"]
    103103[This is a test, John's second story] 
    104104 
    105105# Find all Articles for the Reporter whose ID is 1. 
    106 >>> list(Article.objects.filter(reporter__id__exact=1).order_by('pub_date')
     106>>> Article.objects.filter(reporter__id__exact=1).order_by('pub_date'
    107107[This is a test, John's second story] 
    108 >>> list(Article.objects.filter(reporter__pk=1).order_by('pub_date')
     108>>> Article.objects.filter(reporter__pk=1).order_by('pub_date'
    109109[This is a test, John's second story] 
    110110 
    111111# You need two underscores between "reporter" and "id" -- not one. 
    112 >>> list(Article.objects.filter(reporter_id__exact=1)
     112>>> Article.objects.filter(reporter_id__exact=1
    113113Traceback (most recent call last): 
    114114    ... 
     
    116116 
    117117# You need to specify a comparison clause 
    118 >>> list(Article.objects.filter(reporter_id=1)
     118>>> Article.objects.filter(reporter_id=1
    119119Traceback (most recent call last): 
    120120    ... 
     
    122122 
    123123# "pk" shortcut syntax works in a related context, too. 
    124 >>> list(Article.objects.filter(reporter__pk=1).order_by('pub_date')
     124>>> Article.objects.filter(reporter__pk=1).order_by('pub_date'
    125125[This is a test, John's second story] 
    126126 
     
    141141 
    142142# Reporters can be queried 
    143 >>> list(Reporter.objects.filter(id__exact=1)
     143>>> Reporter.objects.filter(id__exact=1
    144144[John Smith] 
    145 >>> list(Reporter.objects.filter(pk=1)
     145>>> Reporter.objects.filter(pk=1
    146146[John Smith] 
    147 >>> list(Reporter.objects.filter(first_name__startswith='John')
     147>>> Reporter.objects.filter(first_name__startswith='John'
    148148[John Smith] 
    149149 
    150150# Reporters can query in opposite direction of ForeignKey definition 
    151 >>> list(Reporter.objects.filter(article__id__exact=1)
     151>>> Reporter.objects.filter(article__id__exact=1
    152152[John Smith] 
    153 >>> list(Reporter.objects.filter(article__pk=1)
     153>>> Reporter.objects.filter(article__pk=1
    154154[John Smith] 
    155 >>> list(Reporter.objects.filter(article__headline__startswith='This')
     155>>> Reporter.objects.filter(article__headline__startswith='This'
    156156[John Smith, John Smith, John Smith] 
    157 >>> list(Reporter.objects.filter(article__headline__startswith='This').distinct()
     157>>> Reporter.objects.filter(article__headline__startswith='This').distinct(
    158158[John Smith] 
    159159 
    160160# Queries can go round in circles. 
    161 >>> list(Reporter.objects.filter(article__reporter__first_name__startswith='John')
     161>>> Reporter.objects.filter(article__reporter__first_name__startswith='John'
    162162[John Smith, John Smith, John Smith, John Smith] 
    163 >>> list(Reporter.objects.filter(article__reporter__first_name__startswith='John').distinct()
     163>>> Reporter.objects.filter(article__reporter__first_name__startswith='John').distinct(
    164164[John Smith] 
    165165 
     
    171171 
    172172# If you delete a reporter, his articles will be deleted. 
    173 >>> list(Article.objects.order_by('headline')
     173>>> Article.objects.order_by('headline'
    174174[John's second story, Paul's story, This is a test, This is a test, This is a test] 
    175 >>> list(Reporter.objects.order_by('first_name')
     175>>> Reporter.objects.order_by('first_name'
    176176[John Smith, Paul Jones] 
    177177>>> r.delete() 
    178 >>> list(Article.objects.order_by('headline')
     178>>> Article.objects.order_by('headline'
    179179[Paul's story] 
    180 >>> list(Reporter.objects.order_by('first_name')
     180>>> Reporter.objects.order_by('first_name'
    181181[Paul Jones] 
    182182 
  • django/branches/magic-removal/tests/modeltests/many_to_one_null/models.py

    r2157 r2195  
    4747 
    4848# Reporter objects have access to their related Article objects. 
    49 >>> list(r.article_set.order_by('headline')
     49>>> r.article_set.order_by('headline'
    5050[First, Second] 
    51 >>> list(r.article_set.filter(headline__startswith='Fir')
     51>>> r.article_set.filter(headline__startswith='Fir'
    5252First 
    5353>>> r.article_set.count() 
     
    7474 
    7575# To retrieve the articles with no reporters set, use "reporter__isnull=True". 
    76 >>> list(Article.objects.filter(reporter__isnull=True)
     76>>> Article.objects.filter(reporter__isnull=True
    7777[Third] 
    7878""" 
  • django/branches/magic-removal/tests/modeltests/one_to_one/models.py

    r2190 r2195  
    5656DoesNotExist: Restaurant does not exist for {'place__id__exact': ...} 
    5757 
    58 # Restaurant.objects.get_list() just returns the Restaurants, not the Places. 
    59 >>> list(Restaurant.objects.all()
     58# Restaurant.objects.all() just returns the Restaurants, not the Places. 
     59>>> Restaurant.objects.all(
    6060[Demon Dogs the restaurant] 
    6161 
    62 # Place.objects.get_list() returns all Places, regardless of whether they have 
     62# Place.objects.all() returns all Places, regardless of whether they have 
    6363# Restaurants. 
    64 >>> list(Place.objects.order_by('name')
     64>>> Place.objects.order_by('name'
    6565[Ace Hardware the place, Demon Dogs the place] 
    6666 
     
    9292 
    9393# Query the waiters 
    94 >>> list(Waiter.objects.filter(restaurant__place__exact=1)
     94>>> Waiter.objects.filter(restaurant__place__exact=1
    9595[Joe the waiter at Demon Dogs the restaurant] 
    96 >>> list(Waiter.objects.filter(restaurant__pk=1)
     96>>> Waiter.objects.filter(restaurant__pk=1
    9797[Joe the waiter at Demon Dogs the restaurant] 
    98 >>> list(Waiter.objects.filter(id__exact=1)
     98>>> Waiter.objects.filter(id__exact=1
    9999[Joe the waiter at Demon Dogs the restaurant] 
    100 >>> list(Waiter.objects.filter(pk=1)
     100>>> Waiter.objects.filter(pk=1
    101101[Joe the waiter at Demon Dogs the restaurant] 
    102102 
  • django/branches/magic-removal/tests/modeltests/ordering/models.py

    r2190 r2195  
    3939# By default, Article.objects.all() orders by pub_date descending, then 
    4040# headline ascending. 
    41 >>> list(Article.objects.all()
     41>>> Article.objects.all(
    4242[Article 4, Article 2, Article 3, Article 1] 
    4343 
    4444# Override ordering with order_by, which is in the same format as the ordering 
    4545# attribute in models. 
    46 >>> list(Article.objects.order_by('headline')
     46>>> Article.objects.order_by('headline'
    4747[Article 1, Article 2, Article 3, Article 4] 
    48 >>> list(Article.objects.order_by('pub_date', '-headline') 
     48>>> Article.objects.order_by('pub_date', '-headline') 
    4949[Article 1, Article 3, Article 2, Article 4] 
    5050 
    5151# Use the "limit" parameter to limit the results. 
    52 >>> list(Article.objects.order_by('headline')[:3]) 
     52>>> Article.objects.order_by('headline')[:3] 
    5353[Article 1, Article 2] 
    5454 
    5555# Use the "offset" parameter with "limit" to offset the result list. 
    56 >>> list(Article.objects.order_by('headline')[1:3]) 
     56>>> Article.objects.order_by('headline')[1:3] 
    5757[Article 2, Article 3] 
    5858 
    5959# Use '?' to order randomly. (We're using [...] in the output to indicate we 
    6060# don't know what order the output will be in. 
    61 >>> list(Article.objects.order_by('?')
     61>>> Article.objects.order_by('?'
    6262[...] 
    6363""" 
  • django/branches/magic-removal/tests/modeltests/reserved_names/models.py

    r2157 r2195  
    3939h 
    4040 
    41 >>> list(Thing.objects.order_by('when')
     41>>> Thing.objects.order_by('when'
    4242[a, h] 
    4343>>> v = Thing.objects.get(pk='a') 
     
    4646>>> print v.where 
    47472005-01-01 
    48 >>> list(Thing.objects.order_by('select.when')
     48>>> Thing.objects.order_by('select.when'
    4949[a, h] 
    5050 
    51 >>> Thing.objects.get_where_list('year') 
     51>>> Thing.objects.dates('where', 'year') 
    5252[datetime.datetime(2005, 1, 1, 0, 0), datetime.datetime(2006, 1, 1, 0, 0)] 
    5353 
    54 >>> list(Thing.objects.filter(where__month=1)
     54>>> Thing.objects.filter(where__month=1
    5555[a] 
    5656""" 
  • django/branches/magic-removal/tests/modeltests/save_delete_hooks/models.py

    r2190 r2195  
    3131After save 
    3232 
    33 >>> list(Person.objects.all()
     33>>> Person.objects.all(
    3434[John Smith] 
    3535 
     
    3838After deletion 
    3939 
    40 >>> list(Person.objects.all()
     40>>> Person.objects.all(
    4141[] 
    4242"""