ATOMIC_REQUEST and Transactions in Django 1.6
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Music Box Puzzles
--
Chapters
00:00 Question
01:57 Accepted answer (Score 4)
02:55 Thank you
--
Full question
https://stackoverflow.com/questions/2068...
Accepted answer links:
[500.html template]: https://docs.djangoproject.com/en/dev/to...
[handler500]: https://docs.djangoproject.com/en/dev/to...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #django #transactions
#avk47
ACCEPTED ANSWER
Score 4
Your understanding is correct. What you're missing is that letting exceptions propagate from your view code (which is quite different from "propagate all the way up to the user") is a perfectly normal thing to do in Django.
You can customize the resulting behavior by making a 500.html template, by overriding handler500, or by making your own custom middleware. In all of those standard cases, using ATOMIC_REQUESTS will do what you want it to do.
If you want to catch exceptions in your view code and handle them specially, you can certainly do that, you'll just have to specify how to handle transactions manually. Using ATOMIC_REQUESTS is just a way to save some boilerplate for the common case, while allowing you to customize the behavior yourself in the uncommon case.