I have two databases (default database and sample database) . I want to use auth_user
table from sample database not from default database (by default , it is taking from default database ).i want specify it in my model file so that i can access in my views . how is this possible?
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'test',
'USER': 'root',
'PASSWORD': 'test@123',
'HOST': '10.40.40.170',
'PORT': '3306',
},
'sample': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'test1',
'USER': 'root',
'PASSWORD': 'test@123',
'HOST': '10.40.40.170',
'PORT': '3306',
},
}
I have added one extra column for auth_user
table from sample database. I want to use that table. (I can't use auth_user
from default database, because my requirement is like that)
Reference. suppose i have 2 models (test1, test2).test1 is from sample1 database and test2 is from sample2 database.is it possible to mention in model file that test1 should come from sample1 database??
in model.py
class tes1():
class meta:
app_label='users'
db_table='auth_user'
db_label='sample1' #database name here