工作环境Ubuntu,因为买了个固态硬盘,重装了一个系统,之前系统的Django工程移动过来之后,执行python manage syncdb的时候爆出如下错误:
Operations to perform:
Synchronize unmigrated apps: user_notice, user_like, user_profile, front_page, tinymce, user_collect, user_friend, user_blog, user_group, friend_group
Apply all migrations: admin, contenttypes, auth, sessions
Synchronizing apps without migrations:
Creating tables...
Installing custom SQL...
Installing indexes...
Running migrations:
Applying contenttypes.0001_initial...Traceback (most recent call last):
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/base.py", line 533, in handle
return self.handle_noargs(**options)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/commands/syncdb.py", line 27, in handle_noargs
call_command("migrate", **options)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/__init__.py", line 115, in call_command
return klass.execute(*args, **defaults)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/core/management/commands/migrate.py", line 160, in handle
executor.migrate(targets, plan, fake=options.get("fake", False))
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/migrations/executor.py", line 63, in migrate
self.apply_migration(migration, fake=fake)
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/migrations/executor.py", line 91, in apply_migration
if self.detect_soft_applied(migration):
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/migrations/executor.py", line 135, in detect_soft_applied
apps = project_state.render()
File "/usr/local/lib/python2.7/dist-packages/Django-1.7-py2.7.egg/django/db/migrations/state.py", line 71, in render
raise InvalidBasesError("Cannot resolve bases for %r\nThis can happen if you are inheriting models from an app with migrations (e.g. contrib.auth)\n in an app with no migrations; see https://docs.djangoproject.com/en/1.7/topics/migrations/#dependencies for more" % new_unrendered_models)
django.db.migrations.state.InvalidBasesError: Cannot resolve bases for []
This can happen if you are inheriting models from an app with migrations (e.g. contrib.auth)
in an app with no migrations; see https://docs.djangoproject.com/en/1.7/topics/migrations/#dependencies for more
1.后来自己上网查找原因,未果。因为我装的Django的1.7版本的,后来索性看一下是不是Django版本的原因,就装回Django1.6版本,阴差样错的成功了。不知其所以然。写下来希望对大家会有帮助。
2.后来又发现要版本升级后要进行数据迁移,执行 python manage.py migrate 命令就好了。