Alan Tingey
Alan Tingey

Reputation: 971

{{ form.non_field_errors }} with django-crispy-forms

I have the following django form using crispy-forms:

<div class="panel panel-default">
  <div class="panel-heading">
    <h2 class="panel-title">TEAM SELECTION</h2>
  </div>
  <div class="panel-body">
    <form action="" method="post">
        {% csrf_token %}
        <div>{{ form.non_field_errors }}</div>
        <div class="col-xs-12 col-sm-5 col-md-5 col-lg-5">{{ form.team1|as_crispy_field }}</div>
        <div class="col-xs-12 col-sm-5 col-md-5 col-lg-5">{{ form.team2|as_crispy_field }}</div>
        <div class="col-xs-12 col-sm-2 col-md-2 col-lg-2"><button type="submit" class="btn btn-primary btn-block"; margin-bottom: 2cm;>Submit</button></div>
    </form>
  </div>
</div>

Everything looks amazing except the {{ form.non_field_errors }} part. It just looks like a bullet list as follows:

Does anyone know how I can have make the {{ form.non_field_errors }} look as exciting as the rest of the form?

Upvotes: 1

Views: 1759

Answers (1)

Alasdair
Alasdair

Reputation: 309049

Try the as_crispy_errors filter:

{% load crispy_forms_tags %}
{{ form|as_crispy_errors }}

Upvotes: 2

Related Questions