Hello @kartik,
To sync the two models to two databases follow the below code:
Settings.py
# Define the database manager to setup the various projects
DATABASE_ROUTERS = ['manager.router.DatabaseAppsRouter']
DATABASE_APPS_MAPPING = {'mux_data': 't29_db',
'T50_VATC':'t50_db'}
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'fail_over',
'USER': 'SomeUser',
'PASSWORD': 'SomePassword',
'HOST': '127.0.0.1',
'PORT': '',
},
't29_db': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'mux_stage',
'USER': 'SomeUser',
'PASSWORD': 'SomePassword',
'HOST': '127.0.0.1',
'PORT': '',
},
't50_db': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 't50_vatc',
'USER': 'SomeUser',
'PASSWORD': 'SomePassword',
'HOST': '127.0.0.1',
'PORT': '',
},
}
Sample Models
# Create your models here.
class Card_Test(models.Model):
name = models.TextField(max_length=100)
description = models.TextField(max_length=200)
units = models.TextField(max_length=500)
result_tags = models.TextField(max_length=500)
class Meta:
app_label = 'mux_data'
def __unicode__(self):
return self.name
class Status_Type(models.Model):
status = models.CharField(max_length=25)
class Meta:
app_label = 'mux_data'
def __unicode__(self):
return self.status