render_errors.html 844 B

12345678910111213141516171819202122232425262728293031
  1. {% load form_helpers %}
  2. {% load helpers %}
  3. {% if form.errors or form.non_field_errors %}
  4. <div class="alert alert-danger mt-3" role="alert">
  5. <h4 class="alert-heading">Errors</h4>
  6. {% if form.errors and '__all__' not in form.errors %}
  7. <hr />
  8. {% endif %}
  9. <div class="ps-2">
  10. {% if form.errors and '__all__' not in form.errors %}
  11. {% for field_name, errors in form.errors.items %}
  12. {% if not field_name|startswith:'__' %}
  13. {% with field=form|getfield:field_name %}
  14. <strong>{{ field.label }}</strong>
  15. <ul>
  16. {% for error in errors %}
  17. <li>{{ error }}</li>
  18. {% endfor %}
  19. </ul>
  20. {% endwith %}
  21. {% endif %}
  22. {% endfor %}
  23. {% endif %}
  24. {% if form.non_field_errors %}
  25. <hr />
  26. {{ form.non_field_errors }}
  27. {% endif %}
  28. </div>
  29. </div>
  30. {% endif %}