This commit is contained in:
zty 2025-09-12 15:01:12 +08:00
commit 6b08200016
1 changed files with 5 additions and 2 deletions

View File

@ -20,6 +20,7 @@ from drf_yasg.utils import swagger_auto_schema
import json
from django.db import connection
from django.core.exceptions import ObjectDoesNotExist
from django.db.utils import NotSupportedError
class CustomGenericViewSet(MyLoggingMixin, GenericViewSet):
"""
@ -109,9 +110,11 @@ class CustomGenericViewSet(MyLoggingMixin, GenericViewSet):
filter_kwargs = {self.lookup_field: self.kwargs[lookup_url_kwarg]}
try:
obj = queryset.select_for_update().get(**filter_kwargs)
obj = queryset.get(**filter_kwargs)
l_obj = queryset.model.objects.select_for_update().get(pk=obj.pk)
self.check_object_permissions(self.request, obj)
return obj
return l_obj
except ObjectDoesNotExist:
raise Http404
else: