Django not recognizing app_label meta data
Problem
I have multiple DBs to connect to for different apps on my django server, which only serves datas from the DB. I recently added new DB and ran python3 manage.py inspectdb --database=new_db, then I added app_label for correct DB connection. But somehow django is keep returning programming error with invalid object name error. I double checked, and DB and tables are exactly there. Then I found out that model was trying to connect to its default database, which doesn't have table I am trying to connect to. What should I try to fix this?
Summaries
- django model is trying to connect to its default DB, inspite it has explicitly declared target DB on its Meta part.
- DB declaration seems to be fine, because
inspectdbwas done perfectly. - There's no typo on db declaration, too.
<DB declaration on 'settings.py'>
DATABASES = {
'default' : {
'ENGINE' : 'mssql',
'NAME' : 'DEFAULT_DB',
'USER' : env('DB_USER'),
'PASSWORD' : env('DB_PASSWORD'),
'HOST' : env('DB_HOST'),
'PORT' : env('DB_PORT'),
},
'new_db' : {
'ENGINE' : 'mssql',
'NAME' : 'NEW_DB',
'USER' : env('DB_USER'),
'PASSWORD' : env('DB_PASSWORD'),
'HOST' : env('DB_HOST'),
'PORT' : env('DB_PORT'),
}
}
<Meta data of 'models.py'>
class Meta:
managed = False
app_label='new_db'
db_table='NEW_TB'