diff --git a/model_utils/managers.py b/model_utils/managers.py index c9198b0..6df4a40 100644 --- a/model_utils/managers.py +++ b/model_utils/managers.py @@ -6,7 +6,7 @@ from django.db.models.manager import Manager from django.db.models.query import QuerySet -class InheritanceCastQuerySet(QuerySet): +class InheritanceCastMixin(object): def cast(self): results = tuple(self.values_list('pk', 'real_type')) type_to_pks = {} @@ -27,14 +27,6 @@ class InheritanceCastQuerySet(QuerySet): return children -class InheritanceCastManager(models.Manager): - def cast(self): - return self.get_query_set().cast() - - def get_query_set(self): - return InheritanceCastQuerySet(self.model) - - class QueryManager(models.Manager): def __init__(self, *args, **kwargs): if args: diff --git a/model_utils/models.py b/model_utils/models.py index ad265b6..8025add 100644 --- a/model_utils/models.py +++ b/model_utils/models.py @@ -6,7 +6,8 @@ from django.utils.translation import ugettext_lazy as _ from django.db.models.fields import FieldDoesNotExist from django.core.exceptions import ImproperlyConfigured -from model_utils.managers import InheritanceCastManager, QueryManager +from model_utils.managers import manager_from, InheritanceCastMixin, \ + QueryManager from model_utils.fields import AutoCreatedField, AutoLastModifiedField, \ StatusField, MonitorField @@ -20,7 +21,7 @@ class InheritanceCastModel(models.Model): """ real_type = models.ForeignKey(ContentType, editable=False, null=True) - objects = InheritanceCastManager() + objects = manager_from(InheritanceCastMixin) def save(self, *args, **kwargs): if not self.id: