python - Django TypeError: allow_migrate() got an unexpected keyword argument 'model_name' -


so copied on django project new server, replicated environment , imported tables local mysql database.

but when try run makemigrations gives me typeerror: allow_migrate() got unexpected keyword argument 'model_name'

this full stack trace:

traceback (most recent call last):    file "manage.py", line 10, in <module> execute_from_command_line(sys.argv) file "/home/cicd/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line utility.execute() file "/home/cicd/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute self.fetch_command(subcommand).run_from_argv(self.argv) file "/home/cicd/.local/lib/python2.7/site-packages/django/core/management/base.py", line 305, in run_from_argv self.execute(*args, **cmd_options) file "/home/cicd/.local/lib/python2.7/site-packages/django/core/management/base.py", line 353, in execute self.check() file "/home/cicd/.local/lib/python2.7/site-packages/django/core/management/base.py", line 385, in check include_deployment_checks=include_deployment_checks, file "/home/cicd/.local/lib/python2.7/site-packages/django/core/management/base.py", line 372, in _run_checks return checks.run_checks(**kwargs) file "/home/cicd/.local/lib/python2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) file "/home/cicd/.local/lib/python2.7/site-packages/django/core/checks/model_checks.py", line 30, in check_all_models errors.extend(model.check(**kwargs)) file "/home/cicd/.local/lib/python2.7/site-packages/django/db/models/base.py", line 1266, in check errors.extend(cls._check_fields(**kwargs)) file "/home/cicd/.local/lib/python2.7/site-packages/django/db/models/base.py", line 1337, in _check_fields errors.extend(field.check(**kwargs)) file "/home/cicd/.local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 893, in check errors = super(autofield, self).check(**kwargs) file "/home/cicd/.local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 208, in check errors.extend(self._check_backend_specific_checks(**kwargs)) file "/home/cicd/.local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 310, in _check_backend_specific_checks if router.allow_migrate(db, app_label, model_name=self.model._meta.model_name): file "/home/cicd/.local/lib/python2.7/site-packages/django/db/utils.py", line 300, in allow_migrate allow = method(db, app_label, **hints) typeerror: allow_migrate() got unexpected keyword argument 'model_name' 

i appreciate in debugging error , trying understand causing error.

i meet same problem when move 1.6.* 1.10.finally found problem cause database_routers

the old version write

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 rewrite 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


Comments