I want the post
method in the class-based view to be atomic. I have defined the class so:
class AcceptWith(View):
@method_decorator(login_required)
@method_decorator(user_passes_test(my_test))
@method_decorator(transaction.atomic)
def dispatch(self, *args, **kwargs):
return super(AcceptWith, self).dispatch(*args, **kwargs)
Assuming that you're defining your own method to handle the POST
, just apply the transaction.atomic
decorator directly to that method.
class AcceptWith(View):
@transaction.atomic
def post(self, request, *args, **kwargs):
# your code here will be executed atomically
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With