django隐藏所有表格错误 [英] django hide all form errors

查看:53
本文介绍了django隐藏所有表格错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以隐藏用户的所有表单错误消息?我显示自己的消息,并且错误消息显示在表单字段之间的事实对我没有用.

Is there a way to hide all form error messages from the user? I display my own messages and the fact that the error messages are displayed in between the form fields is of no use to me.

推荐答案

您可以自己渲染模板,而忽略错误.请参阅自定义表单模板上的文档了解更多信息.

You can render the template yourself, and just leave out the errors. See the docs on customizing the form template for more info.

或者,默认设置是将错误包含在无序列表中,例如:

Alternatively, the default is for errors to be included in an unordered list, for example:

<ul class="errorlist">
    <li>Sender is required.</li>
</ul>

因此您可以使用CSS隐藏 errorlist 类.

So you could hide the errorlist class with CSS.

ul.errorlist {display:none;}

第三个选择是自定义错误列表格式,但我认为前两个选项更容易.

A third option would be to customize the error list format, but I think the first two options are easier.

这篇关于django隐藏所有表格错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆