Public API¶
Import public classes from django_native_jsonform.
Forms and fields¶
JSONSchemaFormField¶
Composite Django field. Required keyword argument: schema (dictionary, boolean or
callable). Optional arguments:
registry—JSONFormRegistry; defaults to a clone ofdefault_registry;overrides— mapping of path patterns to dictionaries/callables;field_resolver— fallback leaf factory;rendererortemplates— rendering customization;default_policy—preserve(default) ormaterialize;preserve_unknown— preserve undeclared object keys, defaultTrue;max_array_items— safety cap, default250;max_depth,max_nodes— editor budgets, defaults32and5000;schema_resources— referenced schemas keyed by URI;schema_registry— optionalreferencing.Registry;validate_formats— opt-in document format validation, defaultFalse;format_checker— optionaljsonschema.FormatChecker;max_errors— maximum collected document errors, default100;widget_attrs— attributes for the composite root;- normal Django
Fieldkeyword arguments.
JSONSchemaFormMixin¶
Adds context and seeds initial bindings. Place it before forms.Form or an
existing form class.
JSONSchemaModelFormMixin¶
Semantic ModelForm mixin alias.
JSONSchemaModelForm¶
Convenience base combining JSONSchemaModelFormMixin and forms.ModelForm.
Admin¶
JSONSchemaAdminMixin¶
Builds a per-request contextual form. Override
get_json_form_context(request, obj=None) to extend context.
Registry¶
Document validation¶
JSONSchemaValidator(schema, *, schema_registry=None, schema_resources=None,
validate_formats=False, format_checker=None, max_errors=100) is callable and
raises JSONFormValidationError. Its issues(value) returns SchemaIssue
objects containing path, schema_path, keyword, message and pointer.
normalize_schema(schema) returns a copy with legacy UI extensions normalized.
JSONFormRegistry¶
clone()returns an independent shallow copy of registered factories.register_field(json_type, factory=None, *, format=None)supports direct and decorator forms.register_widget(name, factory=None)supports direct and decorator forms.create_field(context)andcreate_widget(...)are normally called by the binding engine.
FieldFactoryContext¶
Immutable dataclass with path, schema, required, disabled, and
form_context.
WidgetFactoryContext¶
Immutable dataclass with path, schema, and form_context.
default_registry¶
Contains standard scalar field factories and the textarea, hidden, and
color widgets. JSONSchemaWidget clones it per widget instance.
Overrides and validation¶
BuildContext¶
Context passed to override callables, explicit field/widget factories, and a
field_resolver.
JSONFormValidationError¶
Django ValidationError subclass accepting errors={path: message_or_list} to
attach errors to generated descendants.
Rendering¶
JSONFormRenderer¶
Template-based renderer. Pass a templates mapping to its constructor or
subclass render() / render_node().
JSONSchemaWidget¶
Composite widget used by JSONSchemaFormField. Most applications configure it
through the field rather than instantiating it directly.