My question below was answered somewhat in past back in 2013 here. But I am looking for more robust and latest solution if there is any.
I have a Django app app1
and I want to tie up data in Django from other databases who are constantly updating on daily basis. For example: In app1
, I have model model
where user has to input sales order from sap and corresponding opportunity number from salesforce. I have tools who dump data from sap into sapdb
and salesforce into salesforcedb
.
My model in app1
looks like:
class SalesOrderMapping(models.Model):
sales_order = models.CharField("Sales Order #", max_length=10, primary_key=True)
opportunity_number = models.CharField("Opportunity Number", max_length=30)
class Meta:
verbose_name_plural = "Sales Order / Opportunity Mapping"
ordering = ('sales_order', 'opportunity_number')
def __str__(self):
return self.sales_order
So as you can see that in above model, I have opportunity_number, I want user to type in sales_order
and instead of typing in opportunity_number
it can be autocomplete text box(ideally) or a drop down populated by a table in salesforcedb
. So far I have been able to describe the databases in settings.py. Can somebody point me in right direction?
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'djangoportal',
'USER': 'myuser',
'PASSWORD': 'mypass',
'HOST': 'localhost', # Or an IP Address that your DB is hosted on
'PORT': '3306',
},
'sap': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'sapdb',
'USER': 'myuser',
'PASSWORD': 'mypass',
'HOST': 'localhost', # Or an IP Address that your DB is hosted on
'PORT': '3306',
},
'sfdc': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'salesforcedb',
'USER': 'myuser',
'PASSWORD': 'mypass',
'HOST': 'localhost', # Or an IP Address that your DB is hosted on
'PORT': '3306',
}
}