我安装了django-axes
它,它允许您设置一个 url,以便在 5 次登录失败时重定向到。我根据文档将此行添加到settings.py:
AXES_LOCKOUT_URL = 'account-locked'
然后我将此行添加到users/urls.py:
path('account/locked/?username=<str>', user_views.account_locked, name='account-locked'),
当我在登录屏幕中输入 5 个不正确的用户名/密码组合时,它会尝试重定向我,但我收到此错误:
NoReverseMatch at /login/
Reverse for 'account-locked?username=user2' not found. 'account-locked?username=user2' is not a valid view function or pattern name.