Friday, May 27, 2016

Database router hints

Hi,

I'm implementing a database router and I need to make use of the model instance which appears in the hints dict. I particularly need the db_for_read() and db_for_write() methods to select the db based on the value of an instance's field

I have found that the instance is in the dict when I use a queryset e.g. Model.objects.filter, but when I get a single instance e.g. Model.objects.get, the instance does not appear - the hints dict is empty.

Could anyone tell me why this is? I need that model instance to be accessible to the db router when getting a single model instance. Am I going about this all wrong by saving a model to a particular db based on an instance's field? The idea is to have a staging version and a production version of a model instance in respective databases.


Thanks,
Mike

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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/30c9e651-a05c-4f14-a7f1-f86daaa6455b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment