[Django] TypeError: allow_migrate() got an unexpected keyword argument 'model_name'

@[TOC]([Django] 报错解决:TypeError: allow_migrate() got an unexpected keyword argument ‘model_name’)

哇这个连书上都没有

感谢万能的大佬

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

作者:东东不邪
来源:CSDN
原文:https://blog.csdn.net/donghustone/article/details/83655411

侵删

发布了9 篇原创文章 · 获赞 2 · 访问量 2348

猜你喜欢

转载自blog.csdn.net/qq_37228688/article/details/86255104
今日推荐