A dynamic JSON-based form engine for Django
Project description
e3-django-dynamic-forms
A dynamic JSON-based form engine for Django. Staff design form schemas via a visual web UI, those schemas render server-side as Django forms, and responses are stored as JSON.
Installation
pip install e3-django-dynamic-forms
Quick Setup
- Add to
INSTALLED_APPS:
INSTALLED_APPS = [
# ...
'rest_framework',
'dynamic_forms',
]
- Include URLs:
urlpatterns = [
path('dynamic-forms/', include('dynamic_forms.urls')),
]
- Run migrations:
python manage.py migrate
- Visit
/dynamic-forms/schemas/to start designing forms.
Templates
The package ships with a built-in base template (dynamic_forms/base.html) so it works out of the box — no need to provide your own base.html.
To use your project's base template instead, set BASE_TEMPLATE in your settings:
DYNAMIC_FORMS = {
'BASE_TEMPLATE': 'my_project/base.html',
}
The only requirement is that your base template defines a {% block content %} block, which is where all dynamic form pages render their content.
Settings
All settings go in a DYNAMIC_FORMS dict in your Django settings:
DYNAMIC_FORMS = {
'BASE_TEMPLATE': 'dynamic_forms/base.html', # Template to extend (default: built-in)
'FIELD_AGENT_CHECK': 'myapp.utils.is_agent', # Custom field agent check
'USER_ADMIN_UNIT': 'myapp.utils.get_admin_unit', # Custom admin unit getter
'ADMIN_UNIT_MODEL': 'myapp.AdminUnit', # Admin unit model (optional)
'STAFF_PERMISSION_MIXIN': 'dynamic_forms.permissions.IsStaffMemberMixin',
'FIELD_AGENT_PERMISSION_MIXIN': 'dynamic_forms.permissions.IsFieldAgentUserMixin',
}
Swappable Attachment Model
Like AUTH_USER_MODEL, you can swap the attachment model:
# settings.py
DYNAMIC_FORMS_ATTACHMENT_MODEL = 'myapp.MyAttachment'
# myapp/models.py
from dynamic_forms.models import AbstractAttachment
class MyAttachment(AbstractAttachment):
extra_field = models.CharField(max_length=255)
class Meta(AbstractAttachment.Meta):
swappable = 'DYNAMIC_FORMS_ATTACHMENT_MODEL'
JSON Schema Format
{
"pages": [
{
"title": "Page 1",
"fields": [
{
"name": "field_name",
"type": "string",
"label": "Field Label",
"required": true,
"help_text": "Help text",
"order": 0,
"validators": {"min_length": 2, "max_length": 100},
"enum": ["opt1", "opt2"],
"multi": false,
"conditions": {
"logic": "AND",
"rules": [
{"field": "other_field", "operator": "equals", "value": "yes"}
]
}
}
]
}
]
}
Supported Field Types
| Type | Description | Validators |
|---|---|---|
string |
Text input | min_length, max_length |
number |
Float input | min_value, max_value |
integer |
Integer input | min_value, max_value |
boolean |
Checkbox | — |
date |
Date picker | min_value, max_value (supports "today") |
file |
File upload | — |
geolocation |
GPS capture button | — |
Add "enum": [...] to string for dropdown, plus "multi": true for checkboxes.
Condition Operators
equals, not_equals, contains, greater_than, less_than, between (format: "min,max")
API Endpoints
GET/POST /dynamic-forms/api/form-schemas/— List/create schemas (staff only)GET/PUT/DELETE /dynamic-forms/api/form-schemas/<uuid>/— Schema detail (staff only)GET/POST /dynamic-forms/api/form-responses/— List (staff) / create (authenticated)GET /dynamic-forms/api/form-responses/<uuid>/— Response detail (staff only)- Filter responses:
?schema=<uuid>
Development
pip install -e ".[dev]"
pytest tests/ -v
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file e3_django_dynamic_forms-0.1.1.tar.gz.
File metadata
- Download URL: e3_django_dynamic_forms-0.1.1.tar.gz
- Upload date:
- Size: 25.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6421352ebe05db426ea032b3e65f9ab5edc7845c2d344f9e372d5d62f456e71
|
|
| MD5 |
8ca3df72d954ec11d37dbf0c8b6066e8
|
|
| BLAKE2b-256 |
93938e5ca02f71e3c174307a6d8ec60bb7faa663744e0ac3fac589263c22edcc
|
File details
Details for the file e3_django_dynamic_forms-0.1.1-py3-none-any.whl.
File metadata
- Download URL: e3_django_dynamic_forms-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfa23a8c5a18192e7dffaa23e06948d855502d614fb94c1e487996ef700bbf85
|
|
| MD5 |
f8f9d6e7a996bc6e821d152829b4db90
|
|
| BLAKE2b-256 |
e41b59efeec1131fde02c797f58a333fbb95180a0255a7b43f52ce3794558f22
|