Hi Vitaliy, thank you for your report.
Using the transaction API from django.db.transaction module directly does not respect the DATABASE_ROUTERS configuration and it does not grab the db_for_write() database alias by default. Instead, it always falls down to django.db.utils.DEFAULT_DB_ALIAS.
Correct, this behaviour is also documentented
atomic takes a using argument which should be the name of a database. If this argument isn’t provided, Django uses the "default" database.
I am changing this from a bug to a feature request as to update the default to be db_for_write() would be a change of behaviour and so needs some thought around deprecations etc.
For cases like this, the recommended path forward is to first propose and discuss the idea/request with the community and gain consensus. To do that, please consider starting a new conversation on the Django Forum, where you'll reach a wider audience and likely get extra feedback.
I'll close the ticket for now, but if there is a community agreement to change this behaviour, you are welcome to come back to the ticket and point to the forum topic, so we can then re-open it. For more details, please see the documented guidelines for requesting features.