stephenmcd/mezzanine — pull request #460 by electroniceagle (2012-10-30 23:03:23+00:00)
Title: InheritanceManager before SearchableManager

Stephen,

This lets you add select_subclasses() to a filter() on Page or Product (anything that uses the DisplayManager) so you can automatically downcast to the appropriate subclass. Only works with a single level of hierarchy. I pulled the code directly from django-model-utils. Discussion of the overhead (essentially select-related turned on) in the second link. Requires Django 1.2+.

https://github.com/carljm/django-model-utils#inheritancemanager
http://jeffelmore.org/2010/11/11/automatic-downcasting-of-inherited-models-in-django/

```
>>> from mezzanine.pages.models import Page
>>> Page.objects.filter().select_subclasses()
[, , , , , , , , , , , , , , , , , , , , '...(remaining elements truncated)...']
>>> Page.objects.filter()
[, , , , , , , , , , , , , , , , , , , , '...(remaining elements truncated)...']
>>> ^D

```