Skip to main content

django-native-jsonform

PyPI Python Django License: MIT

Build nested, server-validated JSON editors from JSON Schema using ordinary Django Field, Widget, Form, and ModelForm primitives.

django-native-jsonform is intended for applications that store configurable data in models.JSONField but still want Django's validation, permissions, widgets, templates, admin integration, and extension points.

Highlights

  • Objects, arrays, nested arrays, choices, local $ref, and discriminated oneOf branches.
  • Native Django fields and server-side validation—no client-only JSON editor.
  • Independent Draft 2020-12 document validation, including composition, conditionals, tuple arrays, dynamic properties and registered references.
  • Replaceable native JSON editors for structures without generated child widgets.
  • Dynamic schemas with access to the current request, user, object, and form.
  • Exact-path, *, and ** overrides for fields, widgets, attributes, serializers, defaults, permissions, and templates.
  • Cloneable registries for project-specific JSON formats and widgets.
  • Sparse JSON preservation: displayed defaults do not have to be persisted.
  • Unknown-key preservation for forward-compatible and permission-aware forms.
  • Template-driven rendering and small progressive-enhancement JavaScript.

Installation

python -m pip install django-native-jsonform
INSTALLED_APPS = [
    # ...
    "django_native_jsonform",
]

Quick start

from django import forms

from django_native_jsonform import JSONSchemaFormField, JSONSchemaModelForm

from .models import Product


PRODUCT_SCHEMA = {
    "type": "object",
    "properties": {
        "title": {"type": "string", "title": "Title"},
        "price": {"type": "number", "minimum": 0},
        "tags": {
            "type": "array",
            "items": {"type": "string"},
        },
    },
    "required": ["title"],
}


class ProductForm(JSONSchemaModelForm):
    metadata = JSONSchemaFormField(schema=PRODUCT_SCHEMA, required=False)

    class Meta:
        model = Product
        fields = "__all__"

For Django admin, add JSONSchemaAdminMixin so callable schemas and factories receive the current request context:

from django.contrib import admin
from django_native_jsonform import JSONSchemaAdminMixin


@admin.register(Product)
class ProductAdmin(JSONSchemaAdminMixin, admin.ModelAdmin):
    form = ProductForm

Customize a project-specific format

from django import forms
from django_native_jsonform import FieldFactoryContext, default_registry

registry = default_registry.clone()


@registry.register_field("string", format="media-asset")
def media_asset_field(context: FieldFactoryContext) -> forms.Field:
    return MediaAssetField(
        user=context.form_context.user,
        schema=context.schema,
        required=context.required,
    )


class ProductForm(JSONSchemaModelForm):
    metadata = JSONSchemaFormField(schema=PRODUCT_SCHEMA, registry=registry)

The package does not depend on a particular rich text editor, media library, autocomplete implementation, or design system. Those are registered by each consumer.

Documentation

The complete wiki lives in docs/ and is published at barcelona-dev.github.io/django-native-jsonform.

Start with the quick start, then see customization and building extensions.

Status

The API is currently alpha. It was extracted from a production Django application, but semantic-versioning compatibility begins with 1.0.

License

MIT

Optional DRF and JSON:API serializers

Generate serializers from your JSON Schema using django_native_jsonform.rest_framework.serializer_from_schema, or attach JSONSchemaField to a model serializer's JSON attribute. Install the drf or jsonapi extra. Opt-in json_api=True converts nested keys using the project's JSON:API formatting configuration while keeping schema validation in one place. See the DRF integration guide for PATCH semantics, references and examples.

Metadata

Release files for django-native-jsonform 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-native-jsonform 0.6.0
File Size Uploaded
django_native_jsonform-0.6.0.tar.gz 66.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-native-jsonform 0.6.0
File Interpreter ABI Platform
django_native_jsonform-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 110.2 kB

Release files / django_native_jsonform-0.6.0.tar.gz

Download URL django_native_jsonform-0.6.0.tar.gz
Size 66.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8a68c7a7f51c4771a0c9f1e697e5e7a3eb9812cdd7562685f74fc21a3c9c9d2a
BLAKE2b-256 checksum
How to use checksums
254bdb421873b924f429d2a4b121bccfeec60c98af594e5efa1c6fb059d83440
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release files / django_native_jsonform-0.6.0-py3-none-any.whl

Download URL django_native_jsonform-0.6.0-py3-none-any.whl
Size 44.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7bdbc68dac4287935492df60c6d5202c91e8d3d1dead0a8ba4e5e0ada8ecfe35
BLAKE2b-256 checksum
How to use checksums
56b1afb381c61b4857fbc7bc07a0108266298471d741d2298b67944ff9fac293
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page