{% extends 'base.html' %} {% autoescape None %} {% block content %} {% module Template( 'modules/header.html', admin=admin, heading='%s / %s' % (admin.name, 'Edit' if obj else 'Add new'), back_button=True, add_button=True, absolute_url=admin.get_absolute_url(handler, obj) if obj else False ) %}
{% if form.errors %}

Error

Please correct the errors in the form before saving

{% end %}
{% for field in form %}
{% if field.type == 'BooleanField' %} {%set input_class = 'custom-control custom-checkbox' %} {% elif field.type == 'RadioField' %} {%set input_class = 'custom-control custom-radio' %} {% elif field.type == 'SelectField' %} {%set input_class = 'custom-select' %} {% else %} {%set input_class = 'form-control' %} {% end %} {% if field.type in ['BooleanField', 'RadioField'] %}
{% if field.errors %} {{ field(class_='custom-control-input is-invalid') }} {{ field.label(class_='custom-control-label') }}
{{ field.errors[0] }}
{% else %} {{ field(class_='custom-control-input') }} {{ field.label(class_='custom-control-label') }} {% end %}
{% else %} {{ field.label }} {% if field.errors %} {{ field(class_=input_class + ' is-invalid') }}
{{ field.errors[0] }}
{% else %} {{ field(class_=input_class) }} {% end %} {% end %}
{% end %}
{% end %}