mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-23 17:28:49 +02:00
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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user