问题描述
E:\SweetYaya\MyProj03>python manage.py migrate
Operations to perform:
Apply all migrations: MyApp, admin, auth, contenttypes, sessions
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "D:\Program Files\Python36\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
utility.execute()
File "D:\Program Files\Python36\lib\site-packages\django\core\management\__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\Program Files\Python36\lib\site-packages\django\core\management\base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "D:\Program Files\Python36\lib\site-packages\django\core\management\base.py", line 398, in execute
output = self.handle(*args, **options)
File "D:\Program Files\Python36\lib\site-packages\django\core\management\base.py", line 89, in wrapped
res = handle_func(*args, **kwargs)
File "D:\Program Files\Python36\lib\site-packages\django\core\management\commands\migrate.py", line 202, in handle
pre_migrate_apps = pre_migrate_state.apps
File "D:\Program Files\Python36\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "D:\Program Files\Python36\lib\site-packages\django\db\migrations\state.py", line 208, in apps
return StateApps(self.real_apps, self.models)
File "D:\Program Files\Python36\lib\site-packages\django\db\migrations\state.py", line 277, in __init__
raise ValueError("\n".join(error.msg for error in errors))
ValueError: The field admin.LogEntry.user was declared with a lazy reference to 'MyApp.sysuser', but app 'MyApp' doesn't provide model 'sysuser'.
找到自己的python3.x,进入site-packages/django/contrib/admin/migrations文件目录下,除了__init__.py文件,其他的全部删除。(注意,切勿把__init__.py文件删了,也不要把contrib/contenttypes这个文件夹下的migrations删了,不然会导致migrate功能失效,就只能把django卸了重下)。