Changes between Version 1 and Version 2 of Ticket #35349


Ignore:
Timestamp:
Apr 2, 2024, 8:10:45 AM (8 months ago)
Author:
Sarah Boyce
Comment:

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.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #35349

    • Property Resolutionfixed
    • Property Status newclosed
    • Property Type BugNew feature
  • Ticket #35349 – Description

    v1 v2  
    44
    55{{{
    6 from django.db import trasnaction
     6from django.db import transaction
    77
    88@transaction.atomic()
Back to Top