carljm/django-model-utils — pull request #102 by dmeehan (2014-01-09 22:47:58+00:00)
Title: Abstracted functionality into mixins so it can be used with any base Manager

This pull request abstracts the additional functionality provided by model_utils managers into Mixins so they can be used with any Manager and not only the django default models.Manager.

My use case is to allow this functionality to be applied to a GeoDjango GeoManager. For example, in my project code, rather than import PassThroughManager from model_utils, I import PassThroughMixin and compose that with GeoManager like so:

from django.contrib.gis.db.models import GeoManager

from model_utils.managers import PassThroughMixin

class PassThroughGeoManager(PassThroughMixin, GeoManager):
pass

Now, I have a GeoManager that also includes the PassThough functionality.

Within model_utils itself, PassThroughManager (etc) still exists as it did before, functions exactly the same, and is completely backwards compatible.

class PassThroughManager(PassThroughMixin, models.Manager):
passs

This pull request allows for a solution to Issue #88 without adding any GeoDjango specific code to the repo.