Python 无法用self显示错误。添加_错误()

Python 无法用self显示错误。添加_错误(),python,django,error-handling,Python,Django,Error Handling,我有个问题,需要你的帮助。 我正在制作一个django网站,以下信息需要验证。若通过注册,将显示成功和失败通知。但也就是说,虽然成功没有问题,但如果失败,通知就不会出现。这是我的表格,有人能帮我吗?非常感谢 if settings.VERIFY_BY_SFID and all([i in cleaned_data for i in fields]): number = cleaned_data["mobile_number"] verified

我有个问题,需要你的帮助。 我正在制作一个django网站,以下信息需要验证。若通过注册,将显示成功和失败通知。但也就是说,虽然成功没有问题,但如果失败,通知就不会出现。这是我的表格,有人能帮我吗?非常感谢

   if settings.VERIFY_BY_SFID and all([i in cleaned_data for i in fields]):
           number = cleaned_data["mobile_number"]
           verified =SignUpFailureAttemptService.verify_mobile_number(number)
           if not verified:
             self.add_error(None, _("Your application was rejected."))
模板

{% extends 'accounts/login_base.html' %} {% load i18n %} {% load staticfiles %} {% load semanticui %} {% load common_templatetags %} {% block welcome_text %} {% trans 'Create your personal
E-wallet account.' %} {% endblock %} {% block slogan_text %} {% trans 'Buy and sell with protection
Easy and secure to send and receive money' %} {% endblock %} {% block bigger_text %} {% blocktrans %}Already have an account?{% endblocktrans %} {% trans 'Sign in' %} {% endblock %} {% block left_content %}
STEPS:
{% include 'accounts/signup/steps.html' with active_step=step steps=5 %} 
{% block form_title %} {{ form_title }} {% endblock %} 
{% if messages %} {% for message in messages %}
{{ message }}
{% endfor %} {% endif %} 
{% block form_block %}
{% csrf_token %} {{ form.non_field_errors }} {% for hidden_field in form.hidden_fields %} {{ hidden_field.errors }} {{ hidden_field }} {% endfor %} {% for field in form.visible_fields %} {% if field.name == 'date_of_birth' %}
{{ field.label }}*
{% endif %}
{% if field.name == 'tos' %} {% blocktrans %} I agree to {% endblocktrans %} PDS and FSG {{ field }}

{% else %} {{ field }} {% endif %}
{{ field.help_text }}
{{ field.errors }} 
{% endfor %}
{% if prev_step %} «   {% trans 'Back' %} {% endif %} 

{% if next_step_title %}
{% trans 'NEXT STEP:' %} {{ next_step_title }}
{% endif %} 
{% endblock %} {% endblock %} {% block scripts_end %} {% endblock %}

你需要显示更多的上下文。这个代码到底在哪里?视图包含什么?模板呢?Telplate base.html如下所示。我上面附加的代码来自form.py,但在表单中的什么位置?您应该显示整个方法,可能还有视图。您是否看到其他错误?