diff options
author | Arthur Koziel <arthur@arthurkoziel.com> | 2010-09-13 00:04:27 +0000 |
---|---|---|
committer | Arthur Koziel <arthur@arthurkoziel.com> | 2010-09-13 00:04:27 +0000 |
commit | dd49269c7db008b2567f50cb03c4d3d9b321daa1 (patch) | |
tree | 326dd25bb045ac016cda7966b43cbdfe1f67d699 /tests/modeltests/custom_managers/models.py | |
parent | c9b188c4ec939abbe48dae5a371276742e64b6b8 (diff) | |
download | django-soc2010/app-loading.tar.gz |
[soc2010/app-loading] merged trunkarchive/soc2010/app-loadingsoc2010/app-loading
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/app-loading@13818 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/modeltests/custom_managers/models.py')
-rw-r--r-- | tests/modeltests/custom_managers/models.py | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/tests/modeltests/custom_managers/models.py b/tests/modeltests/custom_managers/models.py index 40bf77e273..1052552bb3 100644 --- a/tests/modeltests/custom_managers/models.py +++ b/tests/modeltests/custom_managers/models.py @@ -57,51 +57,3 @@ class Car(models.Model): def __unicode__(self): return self.name - -__test__ = {'API_TESTS':""" ->>> p1 = Person(first_name='Bugs', last_name='Bunny', fun=True) ->>> p1.save() ->>> p2 = Person(first_name='Droopy', last_name='Dog', fun=False) ->>> p2.save() ->>> Person.objects.get_fun_people() -[<Person: Bugs Bunny>] - -# The RelatedManager used on the 'books' descriptor extends the default manager ->>> from modeltests.custom_managers.models import PublishedBookManager ->>> isinstance(p2.books, PublishedBookManager) -True - ->>> b1 = Book(title='How to program', author='Rodney Dangerfield', is_published=True) ->>> b1.save() ->>> b2 = Book(title='How to be smart', author='Albert Einstein', is_published=False) ->>> b2.save() - -# The default manager, "objects", doesn't exist, -# because a custom one was provided. ->>> Book.objects -Traceback (most recent call last): - ... -AttributeError: type object 'Book' has no attribute 'objects' - -# The RelatedManager used on the 'authors' descriptor extends the default manager ->>> from modeltests.custom_managers.models import PersonManager ->>> isinstance(b2.authors, PersonManager) -True - ->>> Book.published_objects.all() -[<Book: 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() ->>> Car.cars.order_by('name') -[<Car: Corvette>, <Car: Neon>] ->>> Car.fast_cars.all() -[<Car: 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". ->>> Car._default_manager.order_by('name') -[<Car: Corvette>, <Car: Neon>] -"""} |