Django-Allauth表单错误未显示

时间:2018-07-21 15:31:03

标签: django django-allauth

我有一个自定义Django allauth登录和注册表单,但不包括表单错误。密码错误时,我需要显示自定义错误。 这是自定义表单:

class CustomSignUpForm(SignupForm):
def __init__(self, *args, **kwargs):
    super(CustomSignUpForm, self).__init__(*args, **kwargs)
    for field_name, field in self.fields.items():
        field.widget.attrs['class'] = 'form-control rounded input-lg text-center no-border'

这是实际的形式本身:

      <form id="signup-form" method="POST" action="{% url 'account_signup' %}">
        {% csrf_token %} {% if form.non_field_errors %}
        <div class="alert alert-warning">
          <ul class="alert-message">
            {% for error in form.non_field_errors %}
            <li>{{ error }}</li>
            {% endfor %}
          </ul>
        </div>
        {% endif %}
        <div class="form-group {% if form.email.errors %}has-error{% endif %}">
          {{ form.email }}
        </div>

        <div class="form-group {% if form.username.errors %}has-error{% endif %}">
          {{ form.username }}
        </div>
        <div class="form-group {% if form.password1.errors %}has-error{% endif %}">
          {{ form.password1 }}
        </div>
        <div class="form-group {% if form.password.errors %}has-error{% endif %}">
          {{ form.password2 }}
        </div>
        <button type="submit" class="btn btn-lg btn-warning lt b-white b-2x btn-block btn-rounded"><i class="icon-arrow-right pull-right"></i><span class="m-r-n-lg">Sign Up</span></button>
      </form>

0 个答案:

没有答案