django-jsonform is a Django library that provides a user-friendly form interface for editing JSON data directly within the Django admin. It leverages JSON schema to define the structure of the JSON data, automatically generating dynamic forms for creating and editing. The library also supports PostgreSQL's ArrayField with multiple levels of nesting. As of version 2.23.2, it maintains an active development pace with several releases per year, addressing bugs and introducing new features.
pip install django-jsonformVerified import paths — ran on the pinned version, not inferred.
To quickly integrate `django-jsonform`, define a `JSONField` in your Django model with a corresponding JSON schema. Then, register your model with the Django admin. The library will automatically render a dynamic form based on your schema. Remember to add `django_jsonform` to your `INSTALLED_APPS` and run `collectstatic` for the JavaScript assets to load correctly.
Run `python manage.py collectstatic` after installation or any upgrade.
Manually update existing JSON data in the database to match the new schema structure, or implement custom data migration scripts.
Update your `settings.py` to use `DJANGO_JSONFORM = {'FILE_HANDLER': 'your_app.views.your_handler_view_url'}` instead of `JSONFORM_UPLOAD_HANDLER`.Refactor custom validation logic to utilize `django_jsonform.utils.ErrorMap` for building error dictionaries.
Upgrade to `django-jsonform` version 2.21.5 or newer.
Upgrade to `django-jsonform` version 2.21.3 or newer to resolve Django 4.x layout problems.
Manually migrate the existing JSON data to conform to the new schema, or ensure that new data strictly adheres to the defined schema. The library does not automatically migrate existing JSON data when the schema changes.
First, ensure the package is installed: `pip install django-jsonform`. Then, add `'django_jsonform'` to your `INSTALLED_APPS` in `settings.py`.
Run `python manage.py collectstatic` to gather all static files, and ensure your Django project is configured to serve static files correctly, especially in a production environment. Clear your browser cache during development.
Install the `psycopg2` Python package: `pip install psycopg2-binary`.