【发布时间】:2019-08-19 03:11:58
【问题描述】:
如果表单没有加载错误,我想使用模板标签仅显示某些 html。我在 def clean() 中有这个:
forms.py
home_zipcode = cleaned_data.get('home_zipcode')
if ' ' in home_zipcode:
self.add_error('home_zipcode', "Please remove all spaces from the Zip Code.")
raise forms.ValidationError('Please review the errors below.')
模板
{% if no errors %}
some html
{% endif %}
你知道我会用什么模板标签来做这个吗?
【问题讨论】: