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
Post a Comment