Skip to content Skip to sidebar Skip to footer

Django Login With Django-axes

I created a site with django. Users should be able to login. The login-view looks like this: from django.contrib.auth import authenticate, login from django.contrib.auth.models imp

Solution 1:

By default django-axes used django's login view *(django.contrib.auth.views.login). In middleware this view decorate with watch_login.

So you can solve your issue in two ways:

  • use standard login view. In this way django-axes does not require additional setup.
  • decorate your's login view with watch_login decorator.

For example: views.py

from axes.decorators import watch_login
...

@watch_logindefyour_custom_login_view(request):
    ...

It will then be used like this in class based view as mentioned by @Ali Faizan:

@method_decorator(watch_login, name='dispatch')classyour_custom_login_view():
     ...

Post a Comment for "Django Login With Django-axes"