Django TypeError: allow_migrate() got an unexpected keyword argument 'model_name'
<p>So I copied over my Django project to a new server, replicated the environment and imported the tables to the local mysql database.</p>

<p>But when I try to run makemigrations it gives me the TypeError: allow_migrate() got an unexpected keyword argument 'model_name'</p>

<p>This is the full stack trace:</p>

<pre><code>Traceback (most recent call last):
   File "manage.py", line 10, in &lt;module&gt;
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 an unexpected keyword argument 'model_name'
</code></pre>

<p>I would appreciate any help in debugging this error and trying to understand what is causing this error.</p>

<p>I meet the same problem when i move from 1.6.* to 1.10.Finally i found the problem cause by the <strong>DATABASE_ROUTERS</strong> </p>

<p>the old version i write like this </p>

<pre><code>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
</code></pre>

<p>it work by rewrite like this</p>

<pre><code>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
</code></pre>

<p>more detail see <a href="https://docs.djangoproject.com/en/1.10/topics/db/multi-db/#an-example" rel="nofollow" title="djangoproject">https://docs.djangoproject.com/en/1.10/topics/db/multi-db/#an-example</a></p>

python mysql django