Django-axes在我自己的观点中不适合我。我可以根据需要登录多次。 Axes仍然只能在管理站点上工作,我可以锁定用户。有什么问题?
urls.py:
from axes.decorators import watch_login
from index import views
urlpatterns = [
url(r'^login/$', watch_login(views.Login)),
url(r'^$', views.Login),
url(r'^logout/$', views.Logout),
]
views.py:
def Login(request):
decyptError = False
next = request.GET.get('next', '/index/')
if request.method == "POST":
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:
....
return HttpResponseRedirect(next)
else:
return HttpResponse("Inactive user.")
else:
return HttpResponseRedirect(settings.LOGIN_URL)
return render(request, "index/login.html", {'redirect_to': next})
settings.py:
MIDDLEWARE_CLASSES = (
....
'axes.middleware.FailedLoginMiddleware',
)
INSTALLED_APPS = (
...
'axes',
)