﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33038	Documentation for exception handling and transactions is misleading.	Rich	nobody	"This section of the doc:

https://docs.djangoproject.com/en/3.2/topics/db/transactions/#controlling-transactions-explicitly

Has a warning ""Avoid catching exceptions inside atomic!""

I believe this warning and the associated text is an oversimplification and leads to confusion. For example, this is a very common pattern:

{{{
with transaction.atomic():
  try:
    thing = query.get()
  except ObjectDoesNotExist:
    # Create a new instance or whatever
}}}

The documentation implies that this is to be avoided, despite it being a clean and performant alternative to using ''query.exists()''. The Django source code itself uses this pattern. 

To resolve this I'd like to see it made clear that there is a difference between exceptions which break the transaction (e.g. DatabaseError), and those which don't - the point is already made in the doc about DatabaseError but no counter example of the acceptable uses of exception handling within a transaction is given."	Cleanup/optimization	closed	Documentation	3.2	Normal	wontfix	transactions exceptions		Unreviewed	0	0	0	0	0	0
