【发布时间】:2016-08-15 05:41:50
【问题描述】:
您好,我已经在本地机器上开发了我的项目,但是当我将它转移到服务器上进行生产时,我收到以下错误:
python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 346, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 394, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 445, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/syncdb.py", line 25, in handle
call_command("migrate", **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 120, in call_command
return command.execute(*args, **defaults)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 445, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 93, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 19, in __init__
self.loader = MigrationLoader(self.connection)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 47, in __init__
self.build_graph()
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 321, in build_graph
_reraise_missing_dependency(migration, parent, e)
File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 291, in _reraise_missing_dependency
raise exc
django.db.migrations.graph.NodeNotFoundError: Migration MYapp.0010_auto_20160415_1815 dependencies reference nonexistent parent node (u'registration', u'0003_migrate_activatedstatus')
我刚刚将我的项目从一台机器复制到另一台机器。我的 Django 版本是 1.8.11 有人知道吗? 谢谢
【问题讨论】:
-
您是否有机会在 Django 1.8 的早期版本上创建了其中一些迁移?我在我的一个项目中看到了类似的情况,其中迁移可以使用 1.8.0,然后奇怪地使用 1.8.2 或更高版本,然后突然又开始工作。可能想尝试让它在本地工作,然后在去生产之前为所有东西生成一个 squash_migration。
-
保罗感谢您的回复。我想我已经找到了我的问题......我已经从生产中删除了旧的迁移文件,然后再次运行它......所以现在它正在工作
-
恭喜您解决了这个问题,对于未来,您的错误很可能是由于您的开发(较新)和生产(较旧)版本的软件包的不同版本的“django-registration”引起的。为避免此类错误,请尝试保留
requirements.txt文件,其中所有依赖项均以版本号列出 - 以便能够在相同版本中具有相同的依赖项 - 当然使用 virtualenv :)
标签: python django django-syncdb