{% load i18n %}
{% load main_extras %}
{% block fields %}
  {% if form.autocomplete %}{{ form.autocomplete|json_script:"autocomplete" }}{% endif %}
  {% if form.non_field_errors %}
    <ul class="errorlist">
      {% for error in form.non_field_errors %}<li>{{ error }}</li>{% endfor %}
    </ul>
  {% endif %}
  {% if form.fieldsets %}
    {% for group in form.fieldsets %}
      <div class="column">
        {% for fieldset in group %}
          <div class="fieldset">
            {% for field in fieldset %}
              <div class="field">
                <label for="{{ field.id_for_label }}">{{ field.label }}</label>
                {{ field }}
                {% if field.errors %}
                  <ul class="errorlist">
                    {% for error in field.errors %}
                      <li class="wi">{{ "error-warning"|remix }}{{ error }}</li>
                    {% endfor %}
                  </ul>
                {% endif %}
              </div>
            {% endfor %}
          </div>
        {% endfor %}
      </div>
    {% endfor %}
  {% else %}
    <div class="column">
      {% for field in form %}
        {% if field.errors %}<p class="error">{{ field.errors }}</p>{% endif %}
        <div class="field">
          <label for="{{ field.id_for_label }}">{{ field.label }}</label>
          {{ field }}
        </div>
      {% endfor %}
    </div>
  {% endif %}
  <div class="buttons">
    {% block buttons %}
      {% if form.instance|adding %}
        <input type="submit" value="{% translate "Create" %}">
      {% else %}
        <input type="submit" value="{% translate "Save" %}">
      {% endif %}
      <input type="reset" value="{% translate "Reset" %}">
      {% if not form.instance|adding %}
        <a class="del" href="{{ form.instance.get_delete_url }}">{% translate "Delete" %}</a>
      {% endif %}
    {% endblock buttons %}
  </div>
{% endblock fields %}
