码迷,mamicode.com
首页 > 其他好文 > 详细

django继承修改 User表导致的问题

时间:2018-11-24 17:09:10      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:src   creat   iss   解决   end   otherwise   issue   dynamic   model   

扩展默认的auth_user表参考:

http://www.cnblogs.com/liwenzhou/p/9030211.html#undefined

django继承修改 User表时,python  manage.py  makemigrations进行python  manage.py  migrate操作时会导致的问题如图:

技术分享图片

根源:
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文件夹(除了__init__.py文件)

2.现在执行 python  manage.py  makemigrations 和 python  manage.py  migrate 操作即可成功。


参考博文:

http://www.cnblogs.com/liwenzhou/p/9030211.html#undefined

https://blog.csdn.net/u010377372/article/details/78426372?utm_source=blogxgwz5

 

django继承修改 User表导致的问题

标签:src   creat   iss   解决   end   otherwise   issue   dynamic   model   

原文地址:https://www.cnblogs.com/lixiufeng1994/p/10012657.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!