How to configure 2 databases in Django?

the project uses 3 database and the router database:
DATABASES = {
 'default': {
 (postgres, reading, writing)...
},
 'admission_db': {
 (postgres, reading, writing)...
},
 'journals_db': {
 (mysql only read)...
}
}
DATABASE_ROUTERS = [
'main.lib.DbRouter.DbRouter',
]


the router itself:
class DbRouter:
...

 def allow_migrate(self, db, app_label, model=None, **hints):
 if db == 'admission_db':
 if model and model._meta.app_label == 'admission':
 return True
 return app_label == 'admission'
 elif db == 'journals_db':
 return False
 return None


during migration, indicating the applications and databases
$ python manage.py admission migrate --database admission_db

migrates normally, but if you migrate across
$ python manage.py migrate
an error occurs
django.db.utils.OperationalError: no such table: admission_educationform

how to overcome the problem?
(1.10.5 django, python 3.5.2)

UPD:
changing allow_migrate():
def allow_migrate(self, db, app_label, model=None, **hints):
 if db == 'default':
 if app_label == 'admission':
 return False
 elif model and model._meta.app_label == 'admission':
 return False
 if db == 'admission_db':
 if model and model._meta.app_label == 'admission':
 return True
 return app_label == 'admission'
 elif db == 'journals_db':
 return False
 return None

worked. you have to run 2 of the migration:
$ python manage.py migrate admission
$ python manage.py migrate

But it is not an error.
August 19th 19 at 22:45
2 answers
August 19th 19 at 22:47
Solution
The migrate management command operates on one database at a time. By default, it operates on the default

If, as in the second example above, you've left the default empty database, you must provide a database name each time you run migrate

you can write an alias for all databases or to write your commands-wrapper
added to the router database
if db == 'default':
if app_label == 'admission':
return False
elif model and model._meta.app_label == 'admission':
return False
finally worked fine. however, I have to run 2 of the migration (with the indication of the application that does not use default for the rest), but much less of a problem - isidro27 commented on August 19th 19 at 22:50
August 19th 19 at 22:49
managed to get around the error
$ python manage.py migrate --fake
now Django thinks that the migration is done and no error, but I would like to try to find a solution, so you can just run migrate and no steam

Find more questions by tags DjangoPython