Add-ons for django-forms-builder.
- NoneField (allows to use paragraphs in the django-forms-builder).
Make the following changes in the settings module of your Django project.
- Install
django-nonefield
.
pip install django-nonefield
- Add
form_builder_addons
, to theINSTALLED_APPS
:
INSTALLED_APPS = (
# ...
'form_builder_addons',
# ...
)
- Add the following line somewhere:
# Additional django-forms-builder conf
FORMS_BUILDER_EXTRA_FIELDS = (
(20, 'nonefield.fields.NoneField', gettext("Paragraph")),
)
FORMS_BUILDER_EXTRA_WIDGETS = (
(20, 'nonefield.fields.NoneWidget'),
)
# END Additional django-forms-builder conf
- Add the following line in the "field.html" template of your crispy forms.
{% load form_builder_addons_crispy_form_fields %}
...
{% elif field|is_nonefield %}
<p>{{ field.value }}</p>
...
Full example.
{% load crispy_forms_field form_builder_addons_crispy_form_fields %}
{% if field.is_hidden %}
{{ field }}
{% elif field|is_nonefield %}
<p>{{ field.value }}</p>
{% else %}
... The rest