django hide all form errors

2019-05-25 00:21发布

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.

标签: django forms
1条回答
你好瞎i
2楼-- · 2019-05-25 00:37

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>

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.

查看更多
登录 后发表回答