[Update] 解决select_for_update的错误

pull/2883/head
BaiJiangJie 2019-07-04 17:09:36 +08:00
parent 371aff3251
commit b5962a098a
1 changed files with 5 additions and 5 deletions

View File

@ -38,12 +38,12 @@ class SessionViewSet(OrgBulkModelViewSet):
('date_start', ('date_from', 'date_to'))
]
def get_object(self):
def filter_queryset(self, queryset):
queryset = super().filter_queryset(queryset)
# 解决guacamole更新session时并发导致幽灵会话的问题
obj = super().get_object()
if self.request.method in ('PATCH', ):
obj = obj.select_for_update()
return obj
if self.request.method in ('PATCH',):
queryset = queryset.select_for_update()
return queryset
@property
def filter_backends(self):