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

时间:2016-11-08 21:22:58

标签: django django-crispy-forms

我有以下使用crispy-forms的django表单:

<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>

{{ form.non_field_errors }}部分外,一切看起来都很棒。它看起来像子弹列表如下:

  • 您选择了同一个团队!

有谁知道如何让{{ form.non_field_errors }}看起来像表格的其他部分一样令人兴奋?

1 个答案:

答案 0 :(得分:0)

尝试as_crispy_errors过滤器:

1838399800 - original
4005013284 - my calculation