I have followed the below links before asking this question as it seems like a duplicate, but of no use. So I'm asking again.
Django login with django-axes
django-axes not capturing failed login attempt, but captures admin failed attempts fine
The django-axes works fine with the admin site, but it is unable to capture the failed attempts from the user custom login view. My custom view at '/project/app/views.py' is as follows:
from axes.decorators import watch_login
@watch_login
def user_login(request):
if request.method == 'POST':
username = request.POST.get('username')
password = request.POST.get('password')
......
and in settings.py, the middleware class I'm using is
'axes.middleware.FailedLoginMiddleware'
and the other django-axes configuration is as follows:
AXES_LOGIN_FAILURE_LIMIT = 3 AXES_COOLOFF_TIME = 30 AXES_LOCKOUT_TEMPLATE = '/templates/app/login.html'
and my urls.py is as follows:
from axes.decorators import watch_login
urlpatterns = patterns('',
url(r'^login/$', watch_login(user_login), {'template_name': 'app/login.html'}),
when I try to access the admin page or the user page, I'm getting the following error:
NameError at /admin/
name 'user_login' is not defined
I even tried changing the middleware class from 'axes.middleware.FailedLoginMiddleware' to 'axes.middleware.FailedAdminLoginMiddleware' as suggested in this link, but now nothing seems to work as it showing the error
A server error occurred. Please contact the administrator.
I think I made the question clear.
Any help is appreciated. Thanks