i have followed below links before asking question seems duplicate, of no use. i'm asking again.
django-axes not capturing failed login attempt, captures admin failed attempts fine
the django-axes works fine admin site, unable capture failed attempts user custom login view. custom view @ '/project/app/views.py' 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, middleware class i'm using
'axes.middleware.failedloginmiddleware'
and other django-axes configuration follows:
axes_login_failure_limit = 3 axes_cooloff_time = 30 axes_lockout_template = '/templates/app/login.html'
and urls.py follows:
from axes.decorators import watch_login urlpatterns = patterns('', url(r'^login/$', watch_login(user_login), {'template_name': 'app/login.html'}),
when try access admin page or user page, i'm getting following error:
nameerror @ /admin/
name 'user_login' not defined
i tried changing middleware class 'axes.middleware.failedloginmiddleware' 'axes.middleware.failedadminloginmiddleware' suggested in link, nothing seems work showing error
a server error occurred. please contact administrator.
i think made question clear.
any appreciated. thanks
a year late, hope question , answer useful else. tried out custom login view, , have pretty same setup you, django 1.9.6 , django-axes 1.6. did not wrap user_login
url in watch_login()
because if view's getting called, logically it's getting logged @watch_login
decorator.
it worked fine - logged in several different users , axes created access logs view in admin interface.
your nameerror @ /admin/
seems indicate error not django-axes urls.py - login line (because view getting called when access admin or user login pages, right?). did import app's views, i.e. from app import views
? , need ensure user_login
view's namespace explicit:
url(r'^login/$', watch_login(views.user_login), {'template_name': 'app/login.html'}),...
Comments
Post a Comment