TypeError: isinstance() arg 2 must be a type or tuple of types

版权声明:转载请标明出处 https://blog.csdn.net/gymaisyl/article/details/84454676

TypeError: isinstance() arg 2 must be a type or tuple of types

在进行数据库迁移的时候,我们有时候会很倒霉的碰到这种情况,不要着急,其实解决方案很简单(亲测)

其实主要的原因就是,你在进行数据库迁移的时候,比如,你有一个class User()模型类,但是里面有一个外键,那么,你必须要将这个外键的数据库先进行迁移之后,才能再次对这个外键进行添加并进行迁移;

也就是说:

class User(Model):
	id = XXX,
	name = SSS,
--->like_book = Foreign('book')

class Book(Model):
	id = xxx,
	name  = sss

like_book = Foreign('book') 这个外键在进行迁移的时候,必须是那个Book类进行迁移之后,才可以进行这个外键的迁移操作,否则,就会出错。


我已经在同一个地方摔倒两次,立博客为证,下不为例。。。。

猜你喜欢

转载自blog.csdn.net/gymaisyl/article/details/84454676