我正在使用 Django-axes,并使用与 github 上的自述文件中描述的完全相同的步骤。我可以通过 django 视图很好地登录和注销,但是如果通过主网站,则不会捕获任何失败的登录尝试。尽管如此,来自管理站点的失败登录尝试被很好地捕获。我正在使用 FailedLoginMiddleware,并没有特定于管理员。我已经仔细检查了所有设置和配置,但我仍然无法找到问题的根源。请帮忙。
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'axes.middleware.FailedLoginMiddleware',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'axes',
'django.contrib.admin',
)
这是项目 urls.py:
from django.conf.urls.defaults import patterns, include, url
from django.contrib.auth.views import login, logout, password_change
from qs.forms import ValidatingPasswordChangeForm
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
(r'^login/$', login, {'template_name': 'auth/login.html'}),
(r'^logout/$', logout, {'redirect_field_name': '/login',
'template_name': 'auth/logged_out.html'}),
(r'^passw_change/$', password_change,
{'post_change_redirect': '/rage',
'template_name': 'auth/password_change.html',
'password_change_form': ValidatingPasswordChangeForm}),
(r'^passw_reset/$', 'views.rage_password_reset'),
(r'^passw_reset/done/', 'views.rage_password_reset_done'),
(r'^passw_reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 'views.rage_password_reset_confirm'),
(r'^passw_reset/complete/$', 'views.rage_password_reset_complete'),
url(r'^$', 'be.views.main.index'),
url(r'^admin/', include(admin.site.urls)),
)