django-rest-polymorphic
Polymorphic serializers for Django REST Framework.
What it is and what it does
django-rest-polymorphic bridges django-polymorphic model hierarchies with Django REST Framework's serialization system. It lets you define separate serializers for each model in an inheritance chain, then automatically routes serialization and deserialization through the correct serializer based on the model type. When you query a polymorphic model, the response includes a resource type field that identifies which subclass each object is, and POST/PUT requests use that same field to determine which serializer to apply during deserialization.
The package handles the common pattern of REST APIs that need to work with model inheritance: a base Project model with subclasses like ArtProject and ResearchProject, each with their own fields and serialization rules. Instead of flattening the hierarchy into a single serializer, django-rest-polymorphic lets you preserve the structure and handle each type appropriately.
Use it for:
- API endpoints serving inherited model hierarchies where each subclass has distinct fields and serialization requirements
- REST services that need to return mixed collections of related model types with type information for client routing
- Building polymorphic model APIs where POST/PUT requests specify the resource type to determine which serializer and model to instantiate
- Multi-tenant or plugin architectures where a base model is extended by different subclasses with type-specific logic
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides polymorphic serializers for Django REST Framework that map inherited models created with django-polymorphic to their corresponding serializers, enabling type-aware serialization of model hierarchies.
Yes, if you are using django-polymorphic and need REST API serialization. The package is actively maintained, has low install friction, carries a permissive MIT License, and solves a real gap in Django REST Framework's handling of model inheritance. Verify compatibility with your specific Django and Python versions before adopting.
Install
django-rest-polymorphic on PyPI
pip
pip install django-rest-polymorphicuv
uv add django-rest-polymorphicpoetry
poetry add django-rest-polymorphicInstalling django-rest-polymorphic
Before you install
Low install friction with a pure-Python wheel distribution. The package is actively maintained with a recent commit in 2026, though the latest release was in 2022. Depends on django, djangorestframework, django-polymorphic, and six.
License in practice
MIT License permits commercial and private use with minimal restrictions, requiring only license and copyright notice retention.
Quickstart
pip install django-rest-polymorphic
from django.db import models
from polymorphic.models import PolymorphicModel
class Project(PolymorphicModel):
topic = models.CharField(max_length=30)
class ArtProject(Project):
artist = models.CharField(max_length=30)
Requires django, djangorestframework, and django-polymorphic to be installed and configured; models must be defined using django-polymorphic's PolymorphicModel base class.
Verify before relying
- Whether the package supports Django versions beyond 3.0 (classifiers list only 2.2 and 3.0)
- Current compatibility with modern Python versions (classifiers list up to 3.8, but latest release was 2022)
- Whether the package remains compatible with current versions of its dependencies
Package facts
| License | MIT License (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — django, djangorestframework, django-polymorphic, six |
| Maintenance | actively maintained — 1,489 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,223,149/month — #4,198 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_rest_polymorphic-0.1.10-py2.py3-none-any.whl
Tags
More Dynamic Content packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
soupsieveSoupsieve is a CSS selector library designed to…
permissive · top 100 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
FlaskFlask is a lightweight WSGI web application…
permissive · top 1,000 on PyPI
MakoMako compiles Python-embedded templates into…
permissive · top 1,000 on PyPI
rest-framework-generic-relationsProvides Django REST Framework serializers that…
permissive · top 15,000 on PyPI
drf-writable-nestedExtends Django REST Framework serializers to…
permissive · top 15,000 on PyPI
drf-extra-fieldsProvides specialized serializer fields for…
permissive · top 15,000 on PyPI
django-typomaticGenerates TypeScript interfaces and enums from…
unclear · top 15,000 on PyPI
drf-nested-routersProvides routers and serializer fields for…
permissive · top 5,000 on PyPI
djangorestframeworkBuilds web APIs on top of Django with…
permissive · top 1,000 on PyPI
drf-dynamic-fieldsProvides a Django REST Framework mixin that…
permissive · top 15,000 on PyPI
djangorestframework-role-filtersAdds role-based access control to Django REST…
permissive · top 5,000 on PyPI
drf-rw-serializersExtends Django REST Framework with separate…
permissive · top 15,000 on PyPI
marshmallow-polyfieldExtends Marshmallow with a PolyField class that…
permissive · top 15,000 on PyPI