{% load i18n %}

<form class="form-signin" method="{{ method|default:"POST" }}" enctype="{{ enctype|default:"application/x-www-form-urlencoded" }}">
    {% csrf_token %}
    <div class="text-center mb-4">
        <h1 class="h3 mb-3 font-weight-normal">{% trans title %}</h1>
    </div>

    {% if messages %}
        {% for message in messages %}
            {% if message.tags == 'error' %}
                <div class="alert alert-danger" role="alert">{{ message }}</div>
            {% else %}
                <div class="alert alert-success" role="alert">{{ message }}</div>
            {% endif %}

        {% endfor %}
    {% endif %}

    {% if form.non_field_errors %}
        <div class="form-group">
            {% for error in form.non_field_errors %}
                <div class="alert alert-danger" role="alert">{{ error }}</div>
            {% endfor %}
        </div>
    {% endif %}

    {% for field in form %}
        {% if field.field.widget.input_type == 'checkbox' %}
            <div class="form-group form-check">
                {{ field }}
                <label class="form-check-label" for="{{ field.auto_id }}">{{ field.label|capfirst }}</label>
            </div>
        {% else %}
            <div class="form-group">
                <label for="{{ field.auto_id }}">{{ field.label|capfirst }}</label>
                {{ field }}

                {% for error in field.errors %}
                    <small id="{{ field.auto_id }}" class="form-text text-danger">{{ error }}</small>
                {% endfor %}
            </div>
        {% endif %}
    {% endfor %}
    <button type="submit" class="btn btn-primary">{% trans button %}</button>
</form>
