{"id":6594,"library":"django-jsonform","title":"django-jsonform","description":"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.","status":"active","version":"2.23.2","language":"en","source_language":"en","source_url":"https://www.github.com/bhch/django-jsonform","tags":["django","json","admin","form","schema","widget","json-schema"],"install":[{"cmd":"pip install django-jsonform","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core framework dependency for integration.","package":"Django","optional":false}],"imports":[{"symbol":"JSONField","correct":"from django_jsonform.models.fields import JSONField"},{"note":"Primarily used internally by JSONField, but can be imported for custom form setups.","symbol":"JSONFormWidget","correct":"from django_jsonform.widgets import JSONFormWidget"},{"note":"Required for advanced custom validation to provide field-specific error messages.","symbol":"JSONSchemaValidationError","correct":"from django_jsonform.exceptions import JSONSchemaValidationError"},{"note":"Used in advanced custom validation for mapping errors to specific schema paths.","symbol":"ErrorMap","correct":"from django_jsonform.utils import ErrorMap"}],"quickstart":{"code":"from django.db import models\nfrom django.contrib import admin\nfrom django_jsonform.models.fields import JSONField\n\n# models.py\nclass ShoppingList(models.Model):\n    name = models.CharField(max_length=255)\n    items = JSONField(\n        schema={\n            'type': 'array',\n            'title': 'Shopping Items',\n            'items': {\n                'type': 'dict',\n                'keys': {\n                    'item_name': {'type': 'string', 'title': 'Item Name'},\n                    'quantity': {'type': 'integer', 'title': 'Quantity', 'minimum': 1}\n                }\n            }\n        },\n        help_text='A list of items for shopping.'\n    )\n\n    def __str__(self):\n        return self.name\n\n# admin.py\n# Ensure 'django_jsonform' is in INSTALLED_APPS in settings.py\n@admin.register(ShoppingList)\nclass ShoppingListAdmin(admin.ModelAdmin):\n    list_display = ('name',)\n\n# To see the form in action:\n# 1. Add 'django_jsonform' to INSTALLED_APPS in your settings.py\n# 2. Run 'python manage.py makemigrations' and 'python manage.py migrate'\n# 3. Run 'python manage.py createsuperuser' and log in to the Django admin.","lang":"python","description":"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."},"warnings":[{"fix":"Run `python manage.py collectstatic` after installation or any upgrade.","message":"After installing or upgrading, you must run `python manage.py collectstatic` in your production environment (and often development) to ensure the necessary JavaScript and CSS files are available. Failure to do so will result in the JSON form not rendering correctly or at all.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Manually update existing JSON data in the database to match the new schema structure, or implement custom data migration scripts.","message":"Changing the JSON schema for an existing `JSONField` can lead to discrepancies with pre-existing JSON data. `django-jsonform` does not provide an automatic data migration mechanism; you'll need to manually migrate or transform old JSON data to conform to the new schema, typically from a Django shell.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Update your `settings.py` to use `DJANGO_JSONFORM = {'FILE_HANDLER': 'your_app.views.your_handler_view_url'}` instead of `JSONFORM_UPLOAD_HANDLER`.","message":"The `JSONFORM_UPLOAD_HANDLER` setting for file uploads was deprecated in version 2.11. It is kept for backward compatibility but will be removed in future versions. You should now use the `FILE_HANDLER` key within the main `DJANGO_JSONFORM` settings dictionary.","severity":"deprecated","affected_versions":">=2.11"},{"fix":"Refactor custom validation logic to utilize `django_jsonform.utils.ErrorMap` for building error dictionaries.","message":"When implementing custom validation (e.g., using `JSONSchemaValidationError`), from version 2.15.0 onwards, you should use the `ErrorMap` helper class to construct the `error_map` object. This change was introduced to properly support schema object keys (field names) containing hyphens.","severity":"breaking","affected_versions":">=2.15.0"},{"fix":"Upgrade to `django-jsonform` version 2.21.5 or newer.","message":"Versions prior to 2.21.5 had a bug due to a missing UUID import, which could cause a `NameError` exception when using UUID-related fields.","severity":"gotcha","affected_versions":"<2.21.5"},{"fix":"Upgrade to `django-jsonform` version 2.21.3 or newer to resolve Django 4.x layout problems.","message":"In versions prior to 2.21.3, there were layout issues in Django 4.x, causing the form to render very narrowly in the admin interface.","severity":"gotcha","affected_versions":"<2.21.3"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}