Open jayvdb opened 2 years ago
You can give that via the options
JSONEditorWidget(
options={
"schema": self.acl_schema,
}
)
i used it with dynamic json schema stored in a related model. Id dit it by overriding get_form method :
def get_form(self, request, obj=None, change: bool = False, **kwargs):
my_form = super().get_form(request, obj, change, **kwargs)
categorie_spec = Categorie.objects.get(
id=obj.categorie_id
).specifications_schema
my_form.base_fields["specifications"].widget = JSONEditorWidget(
options={"schema": categorie_spec}
)
return my_form
Description
I would like to supply a JSON-schema to the widget, and the widget ensures that the field content is validate according to the JSON schema provided.