drf-pydantic
Use pydantic with the Django REST framework
Decision gist · record as of 2026-08-14
Yes. The package is production-stable (Development Status 5), has no known vulnerabilities, and solves a real friction point for teams using both pydantic and Django REST framework. Low install friction and active maintenance make it a straightforward addition. Install it if you are building DRF APIs and want to unify your validation layer around pydantic models.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low friction install with only two runtime dependencies (djangorestframework and pydantic).
- Repository shows active maintenance with recent commits and no archived status, though the aging signal suggests releases are spaced further apart.
License · maintenance · safety
MIT (permissive) — MIT license permits free use, modification, and distribution with minimal restrictions—suitable for commercial and open-source projects alike.
last release 2025-12-14 (243 days) · last repo commit 2025-12-14 · 147 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 173,258 downloads/mo, #10,313 on PyPI
Alternatives
Verify before relying
pip install drf-pydantic
from drf_pydantic import BaseModel
class MyModel(BaseModel):
name: str
addresses: list[str]
my_serializer = MyModel.drf_serializer(data={"name": "Van", "addresses": ["Gym"]})
my_serializer.is_valid(raise_exception=True)- Whether the translation from pydantic to DRF serializers handles all pydantic field types and validators without gaps.
- Performance characteristics when validate_pydantic is enabled on large or deeply nested models.
- Compatibility guarantees with specific versions of djangorestframework beyond the runtime dependency declaration.
What it is and what it does
drf-pydantic lets you use pydantic models as the source of truth for data validation in Django REST framework APIs. Instead of writing separate DRF serializers, you define a pydantic model using drf-pydantic's BaseModel, and the package automatically generates an equivalent DRF serializer accessible via the model's drf_serializer attribute. The translation happens at class creation time, so there is no runtime overhead during request handling.
The package supports pydantic v2 and integrates pydantic's validation rules into DRF's serializer validation pipeline. You can enable full pydantic validation by setting validate_pydantic to True in the model's drf_config, which runs pydantic's validators whenever the DRF serializer validates data. It also handles nested models, field customization, and error wrapping so that pydantic ValidationErrors appear as DRF ValidationErrors in your API responses.
Use it for
- Build REST APIs where pydantic models define both your data schema and validation logic, eliminating duplicate serializer definitions.
- Migrate existing pydantic-based services to Django REST framework without rewriting validation rules.
- Leverage pydantic's validation within DRF views for complex field or model-level validation.
- Extend existing pydantic models with DRF serialization by adding drf_pydantic.BaseModel as a parent class.
- Access the fully validated pydantic instance via the pydantic_instance property after validation succeeds.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
The package is production-stable (Development Status 5), has no known vulnerabilities, and solves a real friction point for teams using both pydantic and Django REST framework. Low install friction and active maintenance make it a straightforward addition. Install it if you are building DRF APIs and want to unify your validation layer around pydantic models.
Install
drf-pydantic on PyPI
Before you install
Low friction install with only two runtime dependencies (djangorestframework and pydantic). Repository shows active maintenance with recent commits and no archived status, though the aging signal suggests releases are spaced further apart.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions—suitable for commercial and open-source projects alike.
Quickstart
pip install drf-pydantic
from drf_pydantic import BaseModel
class MyModel(BaseModel):
name: str
addresses: list[str]
my_serializer = MyModel.drf_serializer(data={"name": "Van", "addresses": ["Gym"]})
my_serializer.is_valid(raise_exception=True)
Verify before relying
- Whether the translation from pydantic to DRF serializers handles all pydantic field types and validators without gaps.
- Performance characteristics when validate_pydantic is enabled on large or deeply nested models.
- Compatibility guarantees with specific versions of djangorestframework beyond the runtime dependency declaration.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagesdjangorestframeworkpydantic |
| Maintenance | Aging 243 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 173,258 / month, #10,313 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Information TechnologyIntended Audience :: System AdministratorsLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python ModulesTyping :: Typed |
Evidence: drf_pydantic-2.9.1-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “pydantic django rest framework integration”
- drf-pydanticBridges pydantic models and Django REST framework by automatically…
- django-pydantic-fieldProvides type-safe Pydantic model schemas for Django JSONFields with…
- django-ninjaDjango Ninja builds type-hint-based REST APIs on top of Django, using…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also djangorestframework-dataclasses · django-pydantic-field · pydantic_yaml · drf-recaptcha · pydantic-collections · drf-jsonschema-serializer · pydantic-extra-types · Flask-Pydantic · pydantic-function-models · drf-dynamic-fields