write a custom manager and use it whenever you want to do use other database:
https://docs.djangoproject.com/en/1.3/topics/db/multi-db/#using-get-query-set-with-multiple-databases On Thursday, February 7, 2013 7:08:40 PM UTC+5:30, girishms wrote: > > Hi All, > Is it possible to set db connection manually for each request? > > Here is the senerio: > There are two dbs (lets say:db-1 and db-2) in my application. > I need to use db-1 for some views and db-2 for others. > I know that django creates separate connection for each request, is it > possible to specify > which db to be used during connection.? > > > There is a way to do this for each query by using - "using": > ex: modelname.objects.using('db-name') > But as there are lot of queries in views, its very hard to do for each > query. > > > -- > Girish M S > -- 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+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.