mirror of
https://github.com/jazzband/django-axes.git
synced 2026-05-02 12:44:45 +00:00
Allow using AXES_ONLY_ADMIN_SITE when admin url isn't registered
This commit is contained in:
parent
e57b513aeb
commit
a9789b9df8
1 changed files with 7 additions and 6 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import re
|
||||
|
||||
from django.urls import reverse
|
||||
from django.urls.exceptions import NoReverseMatch
|
||||
|
||||
from axes.conf import settings
|
||||
from axes.helpers import (
|
||||
|
|
@ -158,11 +159,11 @@ class AxesHandler: # pylint: disable=unused-argument
|
|||
"""
|
||||
Checks if the request is for admin site.
|
||||
"""
|
||||
if (
|
||||
settings.AXES_ONLY_ADMIN_SITE
|
||||
and hasattr(request, "path")
|
||||
and not re.match("^%s" % reverse("admin:index"), request.path)
|
||||
):
|
||||
return True
|
||||
if settings.AXES_ONLY_ADMIN_SITE and hasattr(request, "path"):
|
||||
try:
|
||||
admin_url = reverse("admin:index")
|
||||
except NoReverseMatch:
|
||||
return True
|
||||
return not re.match("^%s" % admin_url, request.path)
|
||||
|
||||
return False
|
||||
|
|
|
|||
Loading…
Reference in a new issue