Answer the question
In order to leave comments, you need to log in
Django Rest will transaction fire in decorator?
Hello! In a Django project, I created a decorator to write the history of changes to a separate table
def change_history(a_function_to_decorate):
@transaction.atomic
def wrapper(self, request, *args, **kwargs):
#Код для создания записи в таблице с историей изменения документа
return a_function_to_decorate(self, request, *args, **kwargs)
return wrapper
class HospitalDetailView(HospitalMixin, generics.RetrieveUpdateDestroyAPIView):
@change_history
def put(self, request, *args, **kwargs):
return super().put(request, *args, **kwargs)
@change_history
def delete(self, request, *args, **kwargs):
return super().delete(request, *args, **kwargs)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question