django-axes

8.3.1 · active · verified Sat Apr 11

django-axes is a Django plugin that actively monitors and tracks suspicious login attempts, helping to protect Django-powered sites from brute-force attacks. It can lock out users or IP addresses after a configurable number of failed attempts, supporting various tracking methods like IP, username, and user agent combinations. The library is currently at version 8.3.1 and is actively maintained by the Jazzband community, with a regular release cadence.

Warnings

Install

Imports

Quickstart

To quickly set up django-axes, add 'axes' to `INSTALLED_APPS`, configure `AUTHENTICATION_BACKENDS` to include `AxesStandaloneBackend` at the top, and add `AxesMiddleware` to your `MIDDLEWARE` list, preferably at the end. Finally, run `migrate` to create necessary database tables and `check` to verify your configuration. You can then adjust settings like `AXES_FAILURE_LIMIT` and `AXES_COOLOFF_TIME`.

# settings.py

INSTALLED_APPS = [
    # ... other Django apps
    'axes',
]

AUTHENTICATION_BACKENDS = [
    'axes.backends.AxesStandaloneBackend',  # Must be first
    'django.contrib.auth.backends.ModelBackend',
]

MIDDLEWARE = [
    # ... other Django middleware
    'axes.middleware.AxesMiddleware',  # Should be last if overriding auth response
]

# Optional: Basic configuration
AXES_FAILURE_LIMIT = 5
AXES_COOLOFF_TIME = 60 # In minutes or timedelta object (e.g., timedelta(minutes=30))
# AXES_LOCK_OUT_BY_IP_OR_USERNAME = True # Lock out by IP or username, not both

# Then, run migrations:
# python manage.py migrate
# And check your configuration:
# python manage.py check

view raw JSON →