Hi,
When I once faced this problem I used django-multidb-router. It uses the term "pinning" for the fact that after a query to the master database it "pins" itself to the master database, i.e. uses the master database exclusively for the rest of the request. IIRC it works as you say, with a thread-local variable. It wasn't doing everything I wanted, and merging my pull requests didn't go fast enough, but I maintained my own fork which worked fine for the project I was working on.
Even if you decide not to use it, it will give you ideas on how to implement the things you need.
Regards,
Antonis
Antonis Christofides http://djangodeployment.com
--
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 django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BSd1We3Yq37fYsZu1rVJcxizty6NNG4q-EeVp83wT7aeuh8pQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.