Changeset 2195
- Timestamp:
- 01/30/06 19:08:02 (3 years ago)
- Files:
-
- django/branches/magic-removal/tests/modeltests/basic/models.py (modified) (3 diffs)
- django/branches/magic-removal/tests/modeltests/custom_columns/models.py (modified) (2 diffs)
- django/branches/magic-removal/tests/modeltests/custom_managers/models.py (modified) (3 diffs)
- django/branches/magic-removal/tests/modeltests/custom_methods/models.py (modified) (1 diff)
- django/branches/magic-removal/tests/modeltests/custom_pk/models.py (modified) (3 diffs)
- django/branches/magic-removal/tests/modeltests/lookup/models.py (modified) (2 diffs)
- django/branches/magic-removal/tests/modeltests/m2m_intermediary/models.py (modified) (2 diffs)
- django/branches/magic-removal/tests/modeltests/m2m_multiple/models.py (modified) (1 diff)
- django/branches/magic-removal/tests/modeltests/m2o_recursive2/models.py (modified) (1 diff)
- django/branches/magic-removal/tests/modeltests/m2o_recursive/models.py (modified) (2 diffs)
- django/branches/magic-removal/tests/modeltests/manipulators/models.py (modified) (3 diffs)
- django/branches/magic-removal/tests/modeltests/many_to_many/models.py (modified) (1 diff)
- django/branches/magic-removal/tests/modeltests/many_to_one/models.py (modified) (8 diffs)
- django/branches/magic-removal/tests/modeltests/many_to_one_null/models.py (modified) (2 diffs)
- django/branches/magic-removal/tests/modeltests/one_to_one/models.py (modified) (2 diffs)
- django/branches/magic-removal/tests/modeltests/ordering/models.py (modified) (1 diff)
- django/branches/magic-removal/tests/modeltests/reserved_names/models.py (modified) (2 diffs)
- django/branches/magic-removal/tests/modeltests/save_delete_hooks/models.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/magic-removal/tests/modeltests/basic/models.py
r2190 r2195 14 14 15 15 # No articles are in the system yet. 16 >>> list(Article.objects.all())16 >>> Article.objects.all() 17 17 [] 18 18 … … 41 41 # is represented by "<Article object>", because we haven't given the Article 42 42 # model a __repr__() method. 43 >>> list(Article.objects.all())43 >>> Article.objects.all() 44 44 [<Article object>] 45 45 … … 63 63 <Article object> 64 64 65 >>> list(Article.objects.filter(pub_date__year=2005))65 >>> Article.objects.filter(pub_date__year=2005) 66 66 [<Article object>] 67 >>> list(Article.objects.filter(pub_date__year=2004))67 >>> Article.objects.filter(pub_date__year=2004) 68 68 [] 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) 70 70 [<Article object>] 71 71 django/branches/magic-removal/tests/modeltests/custom_columns/models.py
r2190 r2195 24 24 1 25 25 26 >>> list(Person.objects.all())26 >>> Person.objects.all() 27 27 [John Smith] 28 28 29 >>> list(Person.objects.filter(first_name__exact='John'))29 >>> Person.objects.filter(first_name__exact='John') 30 30 [John Smith] 31 31 … … 33 33 John Smith 34 34 35 >>> list(Person.objects.filter(firstname__exact='John'))35 >>> Person.objects.filter(firstname__exact='John') 36 36 Traceback (most recent call last): 37 37 ... django/branches/magic-removal/tests/modeltests/custom_managers/models.py
r2169 r2195 9 9 class PersonManager(models.Manager): 10 10 def get_fun_people(self): 11 return list(self.filter(fun=True))11 return self.filter(fun=True) 12 12 13 13 class Person(models.Model): … … 69 69 AttributeError: type object 'Book' has no attribute 'objects' 70 70 71 >>> list(Book.published_objects)71 >>> Book.published_objects.all() 72 72 [How to program] 73 73 … … 76 76 >>> c2 = Car(name='Neon', mileage=31, top_speed=100) 77 77 >>> c2.save() 78 >>> list(Car.cars.order_by('name'))78 >>> Car.cars.order_by('name') 79 79 [Corvette, Neon] 80 >>> list(Car.fast_cars)80 >>> Car.fast_cars.all() 81 81 [Corvette] 82 82 83 83 # Each model class gets a "_default_manager" attribute, which is a reference 84 84 # 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') 86 86 [Corvette, Neon] 87 87 """ django/branches/magic-removal/tests/modeltests/custom_methods/models.py
r2125 r2195 19 19 20 20 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) 22 22 23 23 def get_articles_from_same_day_2(self): django/branches/magic-removal/tests/modeltests/custom_pk/models.py
r2190 r2195 30 30 >>> dan = Employee(employee_code='ABC123', first_name='Dan', last_name='Jones') 31 31 >>> dan.save() 32 >>> list(Employee.objects.all())32 >>> Employee.objects.all() 33 33 [Dan Jones] 34 34 35 35 >>> fran = Employee(employee_code='XYZ456', first_name='Fran', last_name='Bones') 36 36 >>> fran.save() 37 >>> list(Employee.objects.all())37 >>> Employee.objects.all() 38 38 [Fran Bones, Dan Jones] 39 39 … … 55 55 >>> fran.last_name = 'Jones' 56 56 >>> fran.save() 57 >>> list(Employee.objects.filter(last_name__exact='Jones'))57 >>> Employee.objects.filter(last_name__exact='Jones') 58 58 [Dan Jones, Fran Jones] 59 59 >>> Employee.objects.in_bulk(['ABC123', 'XYZ456']) … … 64 64 >>> b.set_employees([dan.employee_code, fran.employee_code]) 65 65 True 66 >>> list(b.employee_set)66 >>> b.employee_set.all() 67 67 [Dan Jones, Fran Jones] 68 >>> list(fran.business_set)68 >>> fran.business_set.all() 69 69 [Sears] 70 70 >>> Business.objects.in_bulk(['Sears']) 71 71 {'Sears': Sears} 72 72 73 >>> list(Business.objects.filter(name__exact='Sears'))73 >>> Business.objects.filter(name__exact='Sears') 74 74 [Sears] 75 >>> list(Business.objects.filter(pk='Sears'))75 >>> Business.objects.filter(pk='Sears') 76 76 [Sears] 77 77 78 78 # Queries across tables, involving primary key 79 >>> list(Employee.objects.filter(business__name__exact='Sears'))79 >>> Employee.objects.filter(business__name__exact='Sears') 80 80 [Dan Jones, Fran Jones] 81 >>> list(Employee.objects.filter(business__pk='Sears'))81 >>> Employee.objects.filter(business__pk='Sears') 82 82 [Dan Jones, Fran Jones] 83 83 84 >>> list(Business.objects.filter(employees__employee_code__exact='ABC123'))84 >>> Business.objects.filter(employees__employee_code__exact='ABC123') 85 85 [Sears] 86 >>> list(Business.objects.filter(employees__pk='ABC123'))86 >>> Business.objects.filter(employees__pk='ABC123') 87 87 [Sears] 88 >>> list(Business.objects.filter(employees__first_name__startswith='Fran'))88 >>> Business.objects.filter(employees__first_name__startswith='Fran') 89 89 [Sears] 90 90 django/branches/magic-removal/tests/modeltests/lookup/models.py
r2181 r2195 85 85 # values() returns a list of dictionaries instead of object instances -- and 86 86 # you can specify which fields you want to retrieve. 87 >>> list(Article.objects.values('headline'))87 >>> Article.objects.values('headline') 88 88 [{'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') 90 90 [{'id': 2}, {'id': 3}, {'id': 7}] 91 91 >>> 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'}] … … 142 142 >>> a8 = Article(headline='Article_ with underscore', pub_date=datetime(2005, 11, 20)) 143 143 >>> a8.save() 144 >>> list(Article.objects.filter(headline__startswith='Article'))144 >>> Article.objects.filter(headline__startswith='Article') 145 145 [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_') 147 147 [Article_ with underscore] 148 148 >>> a9 = Article(headline='Article% with percent sign', pub_date=datetime(2005, 11, 21)) 149 149 >>> a9.save() 150 >>> list(Article.objects.filter(headline__startswith='Article'))150 >>> Article.objects.filter(headline__startswith='Article') 151 151 [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%') 153 153 [Article% with percent sign] 154 154 """ django/branches/magic-removal/tests/modeltests/m2m_intermediary/models.py
r2157 r2195 54 54 55 55 # 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') 57 57 [John Smith (Main writer), Jane Doe (Contributor)] 58 58 >>> w1.reporter … … 64 64 >>> w2.article 65 65 This is a test 66 >>> list(r1.writer_set)66 >>> r1.writer_set.all() 67 67 [John Smith (Main writer)] 68 68 """ django/branches/magic-removal/tests/modeltests/m2m_multiple/models.py
r2157 r2195 64 64 # would cause a conflict because the "primary_categories" and 65 65 # "secondary_categories" fields both relate to Category. 66 >>> list(a1.primary_category_set)66 >>> a1.primary_category_set.all() 67 67 [Crime, News] 68 68 69 69 # Ditto for the "primary_category" here. 70 >>> list(a2.primary_category_set)70 >>> a2.primary_category_set.all() 71 71 [News, Sports] 72 72 73 73 # 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() 79 75 [Life] 80 76 81 77 82 >>> list(c1.primary_article_set)78 >>> c1.primary_article_set.all() 83 79 [Area man runs] 84 >>> list(c1.secondary_article_set)80 >>> c1.secondary_article_set.all() 85 81 [] 86 >>> list(c2.primary_article_set)82 >>> c2.primary_article_set.all() 87 83 [Area man steals, Area man runs] 88 >>> list(c2.secondary_article_set)84 >>> c2.secondary_article_set.all() 89 85 [] 90 >>> list(c3.primary_article_set)86 >>> c3.primary_article_set.all() 91 87 [Area man steals] 92 >>> list(c3.secondary_article_set)88 >>> c3.secondary_article_set.all() 93 89 [] 94 >>> list(c4.primary_article_set)90 >>> c4.primary_article_set.all() 95 91 [] 96 >>> list(c4.secondary_article_set)92 >>> c4.secondary_article_set.all() 97 93 [Area man steals, Area man runs] 98 94 """ django/branches/magic-removal/tests/modeltests/m2o_recursive2/models.py
r2157 r2195 33 33 >>> kid.father 34 34 John Smith Senior 35 >>> list(dad.fathers_child_set)35 >>> dad.fathers_child_set.all() 36 36 [John Smith Junior] 37 >>> list(mom.mothers_child_set)37 >>> mom.mothers_child_set.all() 38 38 [John Smith Junior] 39 >>> list(kid.mothers_child_set)39 >>> kid.mothers_child_set.all() 40 40 [] 41 >>> list(kid.fathers_child_set)41 >>> kid.fathers_child_set.all() 42 42 [] 43 43 """ django/branches/magic-removal/tests/modeltests/m2o_recursive/models.py
r2157 r2195 27 27 >>> c.save() 28 28 29 >>> list(r.child_set)29 >>> r.child_set.all() 30 30 [Child category] 31 31 >>> r.child_set.get(name__startswith='Child') … … 36 36 DoesNotExist 37 37 38 >>> list(c.child_set)38 >>> c.child_set.all() 39 39 [] 40 40 >>> c.parent django/branches/magic-removal/tests/modeltests/manipulators/models.py
r2190 r2195 33 33 34 34 # Verify it worked. 35 >>> list(Musician.objects.all())35 >>> Musician.objects.all() 36 36 [Ella Fitzgerald] 37 37 >>> [m1] == list(Musician.objects.all()) … … 67 67 68 68 # Verify it worked. 69 >>> list(Album.objects.all())69 >>> Album.objects.all() 70 70 [Ella and Basie] 71 71 >>> Album.objects.get().musician … … 80 80 81 81 # Verify it worked. 82 >>> list(Album.objects.order_by('name'))82 >>> Album.objects.order_by('name') 83 83 [Ella and Basie, Ultimate Ella] 84 84 >>> a2 = Album.objects.get(pk=2) django/branches/magic-removal/tests/modeltests/many_to_many/models.py
r2190 r2195 57 57 58 58 # Article objects have access to their related Publication objects. 59 >>> list(a1.publication_set)59 >>> a1.publication_set.all() 60 60 [The Python Journal] 61 >>> list(a2.publication_set)61 >>> a2.publication_set.all() 62 62 [The Python Journal, Science News, Science Weekly] 63 63 64 64 # Publication objects have access to their related Article objects. 65 >>> list(p2.article_set)65 >>> p2.article_set.all() 66 66 [NASA uses Python] 67 >>> list(p1.article_set.order_by('headline'))67 >>> p1.article_set.order_by('headline') 68 68 [Django lets you build Web apps easily, NASA uses Python] 69 69 70 70 # 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) 72 72 [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) 74 74 [Django lets you build Web apps easily, NASA uses Python] 75 75 76 >>> list(Article.objects.filter(publications__title__startswith="Science"))76 >>> Article.objects.filter(publications__title__startswith="Science") 77 77 [NASA uses Python, NASA uses Python] 78 78 79 >>> list(Article.objects.filter(publications__title__startswith="Science").distinct())79 >>> Article.objects.filter(publications__title__startswith="Science").distinct() 80 80 [NASA uses Python] 81 81 82 82 # 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) 84 84 [The Python Journal] 85 >>> list(Publication.objects.filter(pk=1))85 >>> Publication.objects.filter(pk=1) 86 86 [The Python Journal] 87 87 88 >>> list(Publication.objects.filter(article__headline__startswith="NASA"))88 >>> Publication.objects.filter(article__headline__startswith="NASA") 89 89 [The Python Journal, Science News, Science Weekly] 90 90 91 >>> list(Publication.objects.filter(article__id__exact=1))91 >>> Publication.objects.filter(article__id__exact=1) 92 92 [The Python Journal] 93 93 94 >>> list(Publication.objects.filter(article__pk=1))94 >>> Publication.objects.filter(article__pk=1) 95 95 [The Python Journal] 96 96 97 97 # If we delete a Publication, its Articles won't be able to access it. 98 98 >>> p1.delete() 99 >>> list(Publication.objects.all())99 >>> Publication.objects.all() 100 100 [Science News, Science Weekly] 101 101 >>> a1 = Article.objects.get(pk=1) 102 >>> list(a1.publication_set)102 >>> a1.publication_set.all() 103 103 [] 104 104 105 105 # If we delete an Article, its Publications won't be able to access it. 106 106 >>> a2.delete() 107 >>> list(Article.objects.all())107 >>> Article.objects.all() 108 108 [Django lets you build Web apps easily] 109 >>> list(p1.article_set.order_by('headline'))109 >>> p1.article_set.order_by('headline') 110 110 [Django lets you build Web apps easily] 111 111 """ django/branches/magic-removal/tests/modeltests/many_to_one/models.py
r2185 r2195 60 60 61 61 # 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') 63 63 [This is a test, John's second story] 64 64 65 >>> list(r.article_set.filter(headline__startswith='This'))65 >>> r.article_set.filter(headline__startswith='This') 66 66 This is a test 67 67 … … 73 73 74 74 # Get articles by id 75 >>> list(Article.objects.filter(id__exact=1))75 >>> Article.objects.filter(id__exact=1) 76 76 [This is a test] 77 >>> list(Article.objects.filter(pk=1))77 >>> Article.objects.filter(pk=1) 78 78 [This is a test] 79 79 80 80 # Query on an article property 81 >>> list(Article.objects.filter(headline__startswith='This'))81 >>> Article.objects.filter(headline__startswith='This') 82 82 [This is a test] 83 83 … … 86 86 # This works as many levels deep as you want. There's no limit. 87 87 # 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') 89 89 [This is a test, John's second story] 90 90 91 91 # 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') 93 93 [This is a test, John's second story] 94 94 … … 100 100 101 101 # 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'"]) 103 103 [This is a test, John's second story] 104 104 105 105 # 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') 107 107 [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') 109 109 [This is a test, John's second story] 110 110 111 111 # 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) 113 113 Traceback (most recent call last): 114 114 ... … … 116 116 117 117 # You need to specify a comparison clause 118 >>> list(Article.objects.filter(reporter_id=1))118 >>> Article.objects.filter(reporter_id=1) 119 119 Traceback (most recent call last): 120 120 ... … … 122 122 123 123 # "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') 125 125 [This is a test, John's second story] 126 126 … … 141 141 142 142 # Reporters can be queried 143 >>> list(Reporter.objects.filter(id__exact=1))143 >>> Reporter.objects.filter(id__exact=1) 144 144 [John Smith] 145 >>> list(Reporter.objects.filter(pk=1))145 >>> Reporter.objects.filter(pk=1) 146 146 [John Smith] 147 >>> list(Reporter.objects.filter(first_name__startswith='John'))147 >>> Reporter.objects.filter(first_name__startswith='John') 148 148 [John Smith] 149 149 150 150 # 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) 152 152 [John Smith] 153 >>> list(Reporter.objects.filter(article__pk=1))153 >>> Reporter.objects.filter(article__pk=1) 154 154 [John Smith] 155 >>> list(Reporter.objects.filter(article__headline__startswith='This'))155 >>> Reporter.objects.filter(article__headline__startswith='This') 156 156 [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() 158 158 [John Smith] 159 159 160 160 # 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') 162 162 [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() 164 164 [John Smith] 165 165 … … 171 171 172 172 # If you delete a reporter, his articles will be deleted. 173 >>> list(Article.objects.order_by('headline'))173 >>> Article.objects.order_by('headline') 174 174 [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') 176 176 [John Smith, Paul Jones] 177 177 >>> r.delete() 178 >>> list(Article.objects.order_by('headline'))178 >>> Article.objects.order_by('headline') 179 179 [Paul's story] 180 >>> list(Reporter.objects.order_by('first_name'))180 >>> Reporter.objects.order_by('first_name') 181 181 [Paul Jones] 182 182 django/branches/magic-removal/tests/modeltests/many_to_one_null/models.py
r2157 r2195 47 47 48 48 # Reporter objects have access to their related Article objects. 49 >>> list(r.article_set.order_by('headline'))49 >>> r.article_set.order_by('headline') 50 50 [First, Second] 51 >>> list(r.article_set.filter(headline__startswith='Fir'))51 >>> r.article_set.filter(headline__startswith='Fir') 52 52 First 53 53 >>> r.article_set.count() … … 74 74 75 75 # 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) 77 77 [Third] 78 78 """ django/branches/magic-removal/tests/modeltests/one_to_one/models.py
r2190 r2195 56 56 DoesNotExist: Restaurant does not exist for {'place__id__exact': ...} 57 57 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() 60 60 [Demon Dogs the restaurant] 61 61 62 # Place.objects. get_list() returns all Places, regardless of whether they have62 # Place.objects.all() returns all Places, regardless of whether they have 63 63 # Restaurants. 64 >>> list(Place.objects.order_by('name'))64 >>> Place.objects.order_by('name') 65 65 [Ace Hardware the place, Demon Dogs the place] 66 66 … … 92 92 93 93 # Query the waiters 94 >>> list(Waiter.objects.filter(restaurant__place__exact=1))94 >>> Waiter.objects.filter(restaurant__place__exact=1) 95 95 [Joe the waiter at Demon Dogs the restaurant] 96 >>> list(Waiter.objects.filter(restaurant__pk=1))96 >>> Waiter.objects.filter(restaurant__pk=1) 97 97 [Joe the waiter at Demon Dogs the restaurant] 98 >>> list(Waiter.objects.filter(id__exact=1))98 >>> Waiter.objects.filter(id__exact=1) 99 99 [Joe the waiter at Demon Dogs the restaurant] 100 >>> list(Waiter.objects.filter(pk=1))100 >>> Waiter.objects.filter(pk=1) 101 101 [Joe the waiter at Demon Dogs the restaurant] 102 102 django/branches/magic-removal/tests/modeltests/ordering/models.py
r2190 r2195 39 39 # By default, Article.objects.all() orders by pub_date descending, then 40 40 # headline ascending. 41 >>> list(Article.objects.all())41 >>> Article.objects.all() 42 42 [Article 4, Article 2, Article 3, Article 1] 43 43 44 44 # Override ordering with order_by, which is in the same format as the ordering 45 45 # attribute in models. 46 >>> list(Article.objects.order_by('headline'))46 >>> Article.objects.order_by('headline') 47 47 [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') 49 49 [Article 1, Article 3, Article 2, Article 4] 50 50 51 51 # Use the "limit" parameter to limit the results. 52 >>> list(Article.objects.order_by('headline')[:3])52 >>> Article.objects.order_by('headline')[:3] 53 53 [Article 1, Article 2] 54 54 55 55 # 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] 57 57 [Article 2, Article 3] 58 58 59 59 # Use '?' to order randomly. (We're using [...] in the output to indicate we 60 60 # don't know what order the output will be in. 61 >>> list(Article.objects.order_by('?'))61 >>> Article.objects.order_by('?') 62 62 [...] 63 63 """ django/branches/magic-removal/tests/modeltests/reserved_names/models.py
r2157 r2195 39 39 h 40 40 41 >>> list(Thing.objects.order_by('when'))41 >>> Thing.objects.order_by('when') 42 42 [a, h] 43 43 >>> v = Thing.objects.get(pk='a') … … 46 46 >>> print v.where 47 47 2005-01-01 48 >>> list(Thing.objects.order_by('select.when'))48 >>> Thing.objects.order_by('select.when') 49 49 [a, h] 50 50 51 >>> Thing.objects. get_where_list('year')51 >>> Thing.objects.dates('where', 'year') 52 52 [datetime.datetime(2005, 1, 1, 0, 0), datetime.datetime(2006, 1, 1, 0, 0)] 53 53 54 >>> list(Thing.objects.filter(where__month=1))54 >>> Thing.objects.filter(where__month=1) 55 55 [a] 56 56 """ django/branches/magic-removal/tests/modeltests/save_delete_hooks/models.py
r2190 r2195 31 31 After save 32 32 33 >>> list(Person.objects.all())33 >>> Person.objects.all() 34 34 [John Smith] 35 35 … … 38 38 After deletion 39 39 40 >>> list(Person.objects.all())40 >>> Person.objects.all() 41 41 [] 42 42 """
