I am trying to create a view in which I save an object, but I would like to cancel it if some kind of exception is thrown. This is what I tried:
class MyView(View): @transation.atomic def post(self, request, *args, **kwargs): try: some_object = SomeModel(...) some_object.save() if something: raise exception.NotAcceptable()
What am I doing wrong? even when an exception some_object is still in the database.
python django atomicity transactions django-database
Gocht
source share