Friday, January 30, 2015

Middleware + Transactions

Dear Django developers,

we currently have the following issue when upgrading from Django 1.5 to Django 1.6:

As it seems, since Django 1.6, middlewares are not supposed to be executed within the same transaction as the view
function is.

We would like to understand why that is the default behavior now and we are supposed to re-organize our code base to
work with that changes.

What is the rationale behind middlewares not being executed within the same transaction as the view function?

Furthermore, decorating all view functions as suggested here is quite not feasible for large projects.
Especially given that reversion is not the only middleware that needs to be executed within the same transaction as the
view function. It would basically mean that each view function needs to be decorated potentially n times.

We understand that transactions might effect performance, thus lesser transactions being in a transaction means faster
execution. However, shouldn't there be the possibility to include distinct middlewares into the view transaction?

Thomas Güttler

Thomas Güttler

You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment