当帐户存在但处于非活动状态时,我试图显示自定义错误消息。为此,我超越了AuthenticationForm's{
forms.py:
class AuthForm(AuthenticationForm):
error_messages = {
'invalid_login': (
"This custom message works"
),
'inactive': (
"This custom message does not."
),
}
url.py:
path('login/', auth_views.LoginView.as_view(
template_name='employees/login.html',
authentication_form=AuthForm),
name='login'),
如您所见,非活动消息不起作用。想一想为什么
编辑:当非活动帐户尝试登录时,将显示invalid_login
消息,而不是inactive
消息
这是Django的a bug which exists。还有another SO thread讨论这个问题
相关问题 更多 >
编程相关推荐