#35520: ModelAdmin uses incorrect database in change and delete views
-----------------------------------------+-----------------------------
               Reporter:  Jake Howard    |          Owner:  Jake Howard
                   Type:  Bug            |         Status:  assigned
              Component:  contrib.admin  |        Version:  dev
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+-----------------------------
 In `ModelAdmin.delete_view` and `ModelAdmin.changelist_view`, the
 transaction is hardcoded to use `db_for_write`, even if the request is
 read-only (eg `GET`). This potentially results in the wrong database being
 selected (or errors if `db_for_write` is used to prevent writing to
 models).

 I propose modifying these calls to use `db_for_read` if the request is
 read-only (`request.method in ("GET", "HEAD", "OPTIONS", "TRACE")`). Most
 users won't notice the difference, as the same database will be selected.
 But those who are using a custom router will get the database they expect.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35520>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070190081337ab-5a08169b-41e6-4963-8573-374d4eca4425-000000%40eu-central-1.amazonses.com.

Reply via email to