--- id: django-pydantic-field version: "0.5.4" license: MIT license_treatment: permissive maintenance: active --- # django-pydantic-field — Type-Safe Pydantic Schemas for Django JSONFields License: permissive · Maintenance: active · Downloads: 1.6M/mo ## What it is and what it does django-pydantic-field bridges Pydantic and Django by allowing you to use Pydantic models as schemas for Django's JSONField. Instead of storing raw JSON and manually validating it, you define a Pydantic model and attach it to a SchemaField—the package then automatically parses incoming JSON into typed Pydantic instances and validates them against your schema. It handles both Pydantic v1 and v2 through a unified API, so you don't need to rewrite code if you upgrade. The package integrates deeply with Django's ecosystem: it works with Django Forms and the Admin interface for validation and editing, provides typed serializers and parsers for Django REST Framework with automatic OpenAPI schema generation, and supports forward references for schemas defined later in your code. Type checkers like mypy and pyright can infer the correct types for your model fields, making it safe to use in statically typed codebases. Use it for: - Store complex nested configuration objects in a Django model with automatic Pydantic validation and type safety. - Build Django REST Framework APIs where request/response bodies are strongly typed Pydantic models with auto-generated OpenAPI docs. - Migrate from raw JSON storage to typed schemas without rewriting your entire data layer. - Use Django Admin to edit JSON data with form validation powered by Pydantic field constraints. - Define forward-referenced schemas that resolve lazily, allowing circular dependencies between models. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides type-safe Pydantic model schemas for Django JSONFields with automatic validation, supporting both Pydantic v1 and v2, and integrating with Django Forms, Admin, and Django REST Framework. Yes. The package is actively maintained, has no known vulnerabilities, low install friction, and solves a real friction point—type-safe JSON storage in Django. It's particularly valuable if you use Django REST Framework and need automatic schema generation, or if you want static type checking on JSON data. The dual Pydantic v1/v2 support makes it safe to adopt even if your environment is in transition. ## Install pip install django-pydantic-field uv add django-pydantic-field poetry add django-pydantic-field ## Installing django-pydantic-field Before you install: Low friction install with three straightforward runtime dependencies. Actively maintained with a recent commit on 2026-02-22 and no known vulnerabilities. License in practice: MIT license permits unrestricted use, modification, and distribution in commercial and private projects with minimal restrictions. Quickstart: pip install django-pydantic-field from django.db import models from django_pydantic_field import SchemaField import pydantic class Foo(pydantic.BaseModel): count: int slug: str = "default" class MyModel(models.Model): foo: Foo = SchemaField() model = MyModel(foo={"count": 42}) model.save() assert isinstance(model.foo, Foo) Requires Python 3.10 or later. Verify before relying: - Whether forward reference resolution handles all edge cases in complex schema hierarchies. - Performance characteristics when handling large nested Pydantic structures in JSONFields. - Compatibility with custom Pydantic validators and field serializers in both v1 and v2. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 1.6M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags django jsonfield pydantic, type-safe django json schema, pydantic django integration, django rest framework pydantic, django admin pydantic models, json validation django, pydantic v1 v2 django, django-integration, pydantic-schemas, type-safety [View on SkillFed](https://skillfed.io/packages/django-pydantic-field) · [View on PyPI](https://pypi.org/project/django-pydantic-field/)