mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
magic-removal: Changed syntax in unit tests -- hopefully for the last time.
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2195 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -8,7 +8,7 @@ from django.db import models
|
||||
|
||||
class PersonManager(models.Manager):
|
||||
def get_fun_people(self):
|
||||
return list(self.filter(fun=True))
|
||||
return self.filter(fun=True)
|
||||
|
||||
class Person(models.Model):
|
||||
first_name = models.CharField(maxlength=30)
|
||||
@@ -68,20 +68,20 @@ Traceback (most recent call last):
|
||||
...
|
||||
AttributeError: type object 'Book' has no attribute 'objects'
|
||||
|
||||
>>> list(Book.published_objects)
|
||||
>>> Book.published_objects.all()
|
||||
[How to program]
|
||||
|
||||
>>> c1 = Car(name='Corvette', mileage=21, top_speed=180)
|
||||
>>> c1.save()
|
||||
>>> c2 = Car(name='Neon', mileage=31, top_speed=100)
|
||||
>>> c2.save()
|
||||
>>> list(Car.cars.order_by('name'))
|
||||
>>> Car.cars.order_by('name')
|
||||
[Corvette, Neon]
|
||||
>>> list(Car.fast_cars)
|
||||
>>> Car.fast_cars.all()
|
||||
[Corvette]
|
||||
|
||||
# Each model class gets a "_default_manager" attribute, which is a reference
|
||||
# to the first manager defined in the class. In this case, it's "cars".
|
||||
>>> list(Car._default_manager.order_by('name'))
|
||||
>>> Car._default_manager.order_by('name')
|
||||
[Corvette, Neon]
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user