参考以下链接设置django支持多数据库时,遇到Django报错:TypeError: allow_migrate() got an unexpected keyword argument 'model_name'
https://www.cnblogs.com/dreamer-fish/p/5469141.html
以下为解决方案:
I meet the same problem when i move from 1.6.* to 1.10.Finally i found the problem cause by the DATABASE_ROUTERS
the old version i write like this
class OnlineRouter(object):
# ...
def allow_migrate(self, db, model):
if db == 'myonline':
return model._meta.app_label == 'online'
elif model._meta.app_label == 'online':
return False
return None
it work by rewrite like this
class OnlineRouter(object):
# ...
def allow_migrate(self, db, app_label, model_name=None, **hints):
if db == 'my_online':
return app_label == 'online'
elif app_label == 'online':
return False
return None
more detail see https://docs.djangoproject.com/en/1.10/topics/db/multi-db/#an-example