1
0
mirror of https://github.com/django/django.git synced 2025-06-05 03:29:12 +00:00

magic-removal: Changed custom_managers unit tests to set core_filters directly rather than _set_core_filter()

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2169 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-01-30 03:40:06 +00:00
parent 85ff60d06a
commit a71574a476

View File

@ -4,7 +4,7 @@
from django.db import models from django.db import models
# An example of providing a custom manager called "objects". # An example of a custom manager called "objects".
class PersonManager(models.Manager): class PersonManager(models.Manager):
def get_fun_people(self): def get_fun_people(self):
@ -19,12 +19,10 @@ class Person(models.Model):
def __repr__(self): def __repr__(self):
return "%s %s" % (self.first_name, self.last_name) return "%s %s" % (self.first_name, self.last_name)
# An example of providing a custom manager that isn't called "objects". # An example of a custom manager that sets a core_filter on its lookups.
class PublishedBookManager(models.Manager): class PublishedBookManager(models.Manager):
def __init__(self): core_filters = {'is_published__exact': True}
super(PublishedBookManager, self).__init__()
self._set_core_filter(is_published__exact=True)
class Book(models.Model): class Book(models.Model):
title = models.CharField(maxlength=50) title = models.CharField(maxlength=50)
@ -38,9 +36,7 @@ class Book(models.Model):
# An example of providing multiple custom managers. # An example of providing multiple custom managers.
class FastCarManager(models.Manager): class FastCarManager(models.Manager):
def __init__(self): core_filters = {'top_speed__gt': 150}
super(FastCarManager, self).__init__()
self._set_core_filter(top_speed__gt=150)
class Car(models.Model): class Car(models.Model):
name = models.CharField(maxlength=10) name = models.CharField(maxlength=10)