老师我按照视频把代码抄了一遍,生成数据库的时候出错,出错信息如下,实在看不懂,请指导一下
来源:4-5 自定义userprofile
qq_青椒肉丝_2
2017-03-09
manage.py@mxonline > makemigrations users "C:\Program Files (x86)\JetBrains\PyCharm 2016.3.2\bin\runnerw.exe" C:\Users\zw\mxonline\Scripts\python.exe "C:\Program Files (x86)\JetBrains\PyCharm 2016.3.2\helpers\pycharm\django_manage.py" makemigrations users E:/mxonline Traceback (most recent call last): File "C:\Program Files (x86)\JetBrains\PyCharm 2016.3.2\helpers\pycharm\django_manage.py", line 41, in <module> run_module(manage_file, None, '__main__', True) File "C:\Python35\Lib\runpy.py", line 196, in run_module return _run_module_code(code, init_globals, run_name, mod_spec) File "C:\Python35\Lib\runpy.py", line 96, in _run_module_code mod_name, mod_spec, pkg_name, script_name) File "C:\Python35\Lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "E:/mxonline\manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "C:\Users\zw\AppData\Roaming\Python\Python35\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line utility.execute() File "C:\Users\zw\AppData\Roaming\Python\Python35\site-packages\django\core\management\__init__.py", line 359, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Users\zw\AppData\Roaming\Python\Python35\site-packages\django\core\management\base.py", line 294, in run_from_argv self.execute(*args, **cmd_options) File "C:\Users\zw\AppData\Roaming\Python\Python35\site-packages\django\core\management\base.py", line 345, in execute output = self.handle(*args, **options) File "C:\Users\zw\AppData\Roaming\Python\Python35\site-packages\django\core\management\commands\makemigrations.py", line 109, in handle loader.check_consistent_history(connection) File "C:\Users\zw\AppData\Roaming\Python\Python35\site-packages\django\db\migrations\loader.py", line 292, in check_consistent_history connection.alias, django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency users.0001_initial on database 'default'. Process finished with exit code 1
12回答
-
慕粉114325746
2018-03-27
先注释掉 admin app
INSTALLED_APPS = [
...
#'django.contrib.admin',
...
]
执行migrate
python manage.py migrate
取消注释
'django.contrib.admin',
都是NB人物,生产环境谁给你删数据库啊,都准备删库跑路吗。
1522018-05-09 -
mike0624
2017-05-30
解决办法:1 删除数据库中所有表除了auth_user。 2 删除migration所有类型0001_initial.py这样的文件。 3 重新执行makemigrations, migrate 命令
70 -
qq_青椒肉丝_2
提问者
2017-03-09
刚看到解决办法了,也解决问题了。
老师的回答:“你是migrate的中间做了自己的操作引起了错误, 你把所有表除了auth_user 表全部删了 然后把所有migration下面的文件全部删了 然后重新migrate试试”
我不明白,“你是migrate的中间做了自己的操作引起了错误” 这句话什么意思? 我写完代码就运行migrate 了啊
422017-03-26 -
yansima
2017-12-22
删除整个数据库,这样就避免有冗余的旧的表存在
然后再makemigrations,migrate
我是Python3.6 和django1.11
毫无疑问,这样比旧的更先进,更谨慎!
新的Python3比起2,django 最新的1.11 有很多细节很好
改进了所有utf8声明,可以直接使用
20 -
Yi罐可乐
2017-04-01
把所有的表删掉,重新 migrate
20 -
慕粉1858163340
2018-02-12
删除数据库重新建又好了,py3 django1.11
00 -
慕粉231728176
2017-10-21
django 1.10 遇到相同问题。按照说明删除所有表后,重新运行命令,解决问题。
00 -
方淇韩FrankFang
2017-10-17
直接删除数据库,新建一个一样的算了,原来的表都删不了
00 -
桂圆
2017-10-14
测试了下在django1.9.8不会出现问题,但是django1.11就会出现这种错误
012018-04-12 -
a72hongjie
2017-08-07
我也遇到了!!!
00 -
慕粉netQ_1642302522
2017-03-26
解决了吗,我也遇到了
012017-03-26 -
慕粉1520115627
2017-03-11
请问你是如何操作的??
00
相似问题