python - Use different models to read data from different databases in django -


i need way of reading data in django different dbs using different models, because models , fields in db have changed between projects.

what try this:

from sbo.core import models sbo_core_models sbo_cloud.core import models cloud_core_models  company_details = sbo_core_models.companydetails.objects.using('sbo').filter(company=sbo_company).order_by("id")[0] new_company_details = cloud_core_models.companydetails.objects.get(id=int(reply['id'])) 

the model gets used new_company_details sbo_core_models.companydetails , not cloud_core_models.companydetails because missing properties appear in second one.

any ideea why might happen , doing wrong, i've seen uses models import first, no matter model tell use.

i using python2.7 , django 1.3.3

all need it's on django documentation https://docs.djangoproject.com/en/1.3/topics/db/multi-db/

i think best solution case database router.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -