【发布时间】:2015-09-25 16:43:51
【问题描述】:
当我尝试为我的 django 应用程序 runserver 时得到的 error 如下:
django.db.migrations.graph.NodeNotFoundError: Migration tasks.0001_initial dependencies 引用不存在的父节点(u'auth', u'0007_alter_validators_add_error_messages')
这发生在我遵循这个 heroku 教程之后:https://devcenter.heroku.com/articles/getting-started-with-django
我修改了设置文件以包含:
import dj_database_url
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = 'staticfiles'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
#DATABASES['default'] = dj_database_url.config()
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'tasks/static'),
)
我的0001_initial迁移如下:
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('auth', '0007_alter_validators_add_error_messages'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
我不知道接下来应该尝试什么来解决此错误。建议赞赏!谢谢!
【问题讨论】:
-
我想我只是通过删除初始迁移下的依赖项来解决此错误。从这个链接:code.djangoproject.com/ticket/21142,这似乎是一个错误。
-
这个问题浏览量很大。您为什么不将此作为答案发布并接受它。它可能会使很多人受益。
-
我可能错了,但我认为他安装了比 Django 1.9 更旧的版本(引入了这种迁移)。
-
你有什么
INSTALLED_APPS?你的应用程序之前有'django.contrib.auth'吗?你试过先做./manage.py migrate auth吗? -
教程已不存在。 OP 自己的修复存在缺陷,很可能忘记在 INSTALLED_APPS 中启用 contrib.auth。是时候关闭这个了。
标签: python django heroku sqlite database-migration