Visual form builder for conjunto: assemble forms and store their definition as JSON.
Project description
conjunto-formbuilder
A visual form builder for conjunto-based Django projects. Forms are
assembled in a UI and stored as JSON — the JSON definition is the contract: build_form(schema) turns it into a
live Django form for rendering, validation and cleaned data, without hand-written field code.
The package depends only on Django and conjunto, so it runs in any conjunto project.
Install
pip install conjunto-formbuilder
# settings.py
INSTALLED_APPS = [
# …
"conjunto_formbuilder",
]
Concept
[ Builder UI ] ──► schema (JSON) ──► build_form(schema) ──► Django Form
A field descriptor carries more than type/label/required: grid layout coordinates (x/y/w/h) and optional
source (queryset autocomplete) / provision (prefill from a registered data source) descriptors.
from conjunto_formbuilder.build import build_form
schema = {
"version": 1,
"layout": "grid",
"columns": 12,
"fields": [
{"name": "first_name", "type": "text", "label": "First name", "required": True,
"grid": {"x": 0, "y": 0, "w": 6, "h": 1}},
{"name": "birth_date", "type": "date", "label": "Date of birth",
"grid": {"x": 6, "y": 0, "w": 6, "h": 1}},
],
}
form = build_form(schema, data=request.POST or None)
if form.is_valid():
... # form.cleaned_data
Extending
- Field types — register a
FieldTypewithconjunto_formbuilder.registry.register_field_type.
Data sources
A field's source (autocomplete) and provision (prefill) descriptors never name a model or queryset directly — that
would let a stored form definition reach into arbitrary tables. Instead they name a provider by its key. A
provider is a conjunto_formbuilder.datasources.IDataSource (a GDAPS interface) you implement; it returns data through
its own, typically tenant-aware, queryset and is responsible for validating the params it accepts.
from conjunto_formbuilder.datasources import IDataSource
from myapp.models import Country
class CountrySource(IDataSource):
"""Generic model-queryset provider: autocomplete + prefill for countries."""
key = "myapp.country"
def get_queryset(self, request, params):
# Scope here (tenant, permissions, params) — this is the trust boundary.
return Country.objects.all()
def search(self, request, params, query):
# Candidates for the typed query; the options partial renders each as
# ``{{ obj.pk }}`` / ``{{ obj }}``.
return self.get_queryset(request, params).filter(name__icontains=query)[:20]
def resolve(self, request, params):
# A single value to prefill the field with, or ``None``.
return self.get_queryset(request, params).values_list("pk", flat=True).first()
Reference it from a field:
{"name": "country", "type": "autocomplete",
"source": {"provider": "myapp.country", "params": {}},
"provision": {"provider": "myapp.country", "params": {}}}
build_form wires the autocomplete widget's URL to the AutocompleteOptionsView, carrying the provider key (and any
params) as query arguments; the widget sends the typed text as ?q=…. The view resolves the provider against the
registry only — an unknown key yields 404. When the builder URLs are mounted under a different namespace, override the
reversed URL name via the autocomplete_url_name= argument of build_form_class or the
CONJUNTO_FORMBUILDER_AUTOCOMPLETE_URL_NAME setting.
License
AGPL-3.0-or-later.
Project details
Release history Release notifications | RSS feed
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 conjunto_formbuilder-0.1.0.tar.gz.
File metadata
- Download URL: conjunto_formbuilder-0.1.0.tar.gz
- Upload date:
- Size: 41.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"KDE neon","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25a86812ef8cf87507786fbb909ff9edb2074d9047ebff383caaebe3a06322a4
|
|
| MD5 |
48315666a27794bf1bb66414bf6611ac
|
|
| BLAKE2b-256 |
384806db416c67789d08d9e2aa72b35297da1c956de530391fa087dd6cda6979
|
File details
Details for the file conjunto_formbuilder-0.1.0-py3-none-any.whl.
File metadata
- Download URL: conjunto_formbuilder-0.1.0-py3-none-any.whl
- Upload date:
- Size: 40.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"KDE neon","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85a86062b6981af6f4cfd0bbf18cd085b1471ce2846176902605b062f153d3d0
|
|
| MD5 |
aebb89d9219d2cabfd22c0a9825b116f
|
|
| BLAKE2b-256 |
ede40122abddb93842a2967fc5e87796e265c53c151bdc6a983b6db83cb2a581
|