Django - 自定义认证后端中的错误消息 [英] Django - Error Message in Custom Auth Backend

查看:151
本文介绍了Django - 自定义认证后端中的错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过扩展defalut ModelBackend编写了一个定制的auth后端。是否可以向登录屏幕发送自定义错误消息?截至目前,它正在显示默认消息。

解决方案

错误消息来自 ValidationError django.contrib.auth.forms.AuthenticationForm 引发的异常。您需要扩展认证表单或实施自己的认证表单来更改其错误消息。


I have written a custom auth backend by extending the defalut ModelBackend. Is it possible to send a custom error message to login screen? As of now it is displaying the default message.

解决方案

The error messages are coming as ValidationError exceptions raised by django.contrib.auth.forms.AuthenticationForm. You would need to extend the Authentication Form or implement your own authentication form to change it's error messages.

这篇关于Django - 自定义认证后端中的错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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