19644 Make atomic use correct database instead of default (#19651)

* 19644 set atomic transactions to appropriate database

* 19644 set atomic transactions for Job Script run

* 19644 set atomic transactions to appropriate database

* 19644 set atomic transactions to appropriate database

* 19644 fix review comments

* 19644 fix review comments
This commit is contained in:
Arthur Hanson
2025-06-25 12:00:26 -07:00
committed by GitHub
parent f97d07a11c
commit a17699d261
11 changed files with 44 additions and 41 deletions

View File

@@ -2,7 +2,7 @@ from copy import deepcopy
from django.contrib.contenttypes.prefetch import GenericPrefetch
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
from django.db import transaction
from django.db import router, transaction
from django.shortcuts import get_object_or_404
from django.utils.translation import gettext as _
from django_pglocks import advisory_lock
@@ -295,7 +295,7 @@ class AvailableObjectsView(ObjectValidationMixin, APIView):
# Create the new IP address(es)
try:
with transaction.atomic():
with transaction.atomic(using=router.db_for_write(self.queryset.model)):
created = serializer.save()
self._validate_objects(created)
except ObjectDoesNotExist: