My view "a" calls a view "b" that adds items to the database.
Then my view "a" raises an exception.
The items created in the view "b" are in the database.
I tried to write a proper test in django to reproduce the failure but I
think it is not working properly:
https://github.com/do3cc/django/commit/c9d7be5fde722b552dd4cb6276b1a1edf201f53f
I use a settings file that activates postgres and the test gets executed
but I suspect that I must use the client to access the views.
This is roughly the code in question:
I'd love to write a better testcase for it but I am a bit lost at the
moment where to write that test case.
--
Ticket URL: <https://code.djangoproject.com/ticket/27894>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => invalid
Comment:
That's an interesting question, but I'm not convinced ATOMIC_REQUESTS
should apply to that case.
As the word REQUESTS in ATOMIC_REQUESTS implies, the atomicity is tied to
an incoming HTTP request, and there's no HTTP request going through
Django's HTTP / WSGI stack when the second view is called.
A view is just a Python function. Django isn't going to interfere when you
call that function. You should wrap the call to the second view in an
atomic block yourself when you call it to achive the desired effect.
--
Ticket URL: <https://code.djangoproject.com/ticket/27894#comment:1>