Extends Django model inheritance so base-model queries return concrete subclass instances instead of the parent type.
Overview
Django Polymorphic builds on standard Django model inheritance and makes working with subclassed models more natural. When you query at the base model level, results come back as the actual inherited model classes rather than only the parent class, which vanilla Django often returns.
The package integrates with the Django admin, ORM relations such as foreign keys, many-to-many fields, and one-to-one fields, and supports filtering and ordering on inherited fields. You can filter by concrete types using instanceof-style helpers, union querysets from different models, use custom managers, and turn polymorphic behavior off when needed.
Formsets, proxy models, and optional integrations with projects such as django-guardian, django-extra-views, django-reversion, and model-bakery appear in the documentation. Each subclass may require extra joins when fetching data, which the authors note as a performance consideration.
Compared with plain Django inheritance, the focus is automatic downcasting and type-aware querying so applications that model several subtypes under one base can load and administer them as their real types.
Key features
- Admin integration for polymorphic models
- ORM support for FK, M2M, and O2O
- instanceof and notinstanceof filtering
- Combine querysets from different models
- Custom user-defined managers
- Minimal queries for inherited rows
- Optional non-polymorphic queries
- Formset and proxy model support
Use cases
- Multiple project subtypes under one base model
- Admin lists showing real subclass instances
- Filtering queryset results by concrete model type
- Relations that resolve to polymorphic targets