Database router hints

32 views
Skip to first unread message

Mike Q

unread,
May 27, 2016, 11:52:24 AM5/27/16
to Django users
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
Reply all
Reply to author
Forward
0 new messages