A widget for the Django JSONFIELD, this widget usefulness is to have dynamic fields for a given model.
Project description
Installation
Install the package with pip install django_jsonfield_widget
Then add it to the INSTALLED_APPS in settings.py :
INSTALLED_APPS = [
'...',
'django_jsonfield_widget',
'...'
]
JsonFieldSchemaWidget
The JsonFieldSchemaWidget is a widget that adds a fixed schema to the json. The Json is blocked in this canvas and cannot be adapted by the enduser when this widget is used. This widget was developped to create dynamic form schemas where the dynamic fields are controlled by python code
To use the JsonFieldSchemaWidget in a form do:
from django_jsonfield_widget.widgets import JsonFieldSchemaWidget
from collections import OrderedDict
class SomeForm(forms.ModelForm):
class Meta:
model = SomeModel
fields = '__all__'
widgets = {
'json_field': JsonFieldSchemaWidget(schema=OrderedDict({
'height': {
'verbose_name': 'What is your height in cm?',
'type': 'IntegerField'
},
'name': {
'verbose_name': 'What is your name?',
'type': 'CharField',
},
'has_freckless': {
'verbose_name': 'Do you have freckless?',
'type': 'BooleanField',
}
})),
}
About
developped by : DEUSE - Développement Software
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
Close
Hashes for django_jsonfield_widget-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9ec4940714166a1fc821800fc92202b3de9d9d35744dc7a1aa11d887c900392 |
|
MD5 | d9aeb2870aa974740457463d494b0f91 |
|
BLAKE2b-256 | 5232ea544d75b26c7997624144d7a1c0ae6f0bf54d1c07b48f6a24b23b65bb74 |