mirror of
https://github.com/jazzband/django-axes.git
synced 2026-03-16 22:30:23 +00:00
fix: fix TransactionManagementError
This commit is contained in:
parent
5f52f4383f
commit
4861f3c988
1 changed files with 4 additions and 4 deletions
|
|
@ -1,8 +1,8 @@
|
|||
from logging import getLogger
|
||||
from typing import Optional
|
||||
|
||||
from django.db import transaction
|
||||
from django.db.models import F, Sum, Value, Q
|
||||
from django.db import router, transaction
|
||||
from django.db.models import F, Q, Sum, Value
|
||||
from django.db.models.functions import Concat
|
||||
from django.utils import timezone
|
||||
|
||||
|
|
@ -171,7 +171,7 @@ class AxesDatabaseHandler(AbstractAxesHandler, AxesBaseHandler):
|
|||
"AXES: Username is None and username is the only one lockout parameter, new record will NOT be created."
|
||||
)
|
||||
else:
|
||||
with transaction.atomic():
|
||||
with transaction.atomic(using=router.db_for_write(AccessAttempt)):
|
||||
(
|
||||
attempt,
|
||||
created,
|
||||
|
|
@ -243,7 +243,7 @@ class AxesDatabaseHandler(AbstractAxesHandler, AxesBaseHandler):
|
|||
|
||||
# 5. database entry: Log for ever the attempt in the AccessFailureLog
|
||||
if settings.AXES_ENABLE_ACCESS_FAILURE_LOG:
|
||||
with transaction.atomic():
|
||||
with transaction.atomic(using=router.db_for_write(AccessFailureLog)):
|
||||
AccessFailureLog.objects.create(
|
||||
username=username,
|
||||
ip_address=request.axes_ip_address,
|
||||
|
|
|
|||
Loading…
Reference in a new issue