django继承修改 User表导致的问题 fields.E304(permissions/group都会有这样的错误)

问题:

django继承修改 User表时,进行migrations操作时会导致的问题 fields.E304(permissions/group都会有这样的错误)如图:

根源:

django文档中有注明:

Due to limitations of Django’s dynamic dependency feature for swappablemodels, the model referenced by AUTH_USER_MODEL must be created inthe first migration of its app (usually called 0001_initial); otherwise,you’ll have dependency issues.

因此如果涉及到修改用户表,一定要保证用户表的migration编号是0001_,否则会有依赖性问题。因为其他的权限表什么的已经简历了,


解决办法:

1.清空数据库,清除文件中的migrations文件夹(我是全删除了,)

2.先给User所在的表做migrations操作,然后再做其他的migrations做到

3.migrate

4.解决问题请点赞哈哈


原文地址:https://www.cnblogs.com/hiveme/p/8194818.html