【发布时间】:2013-11-10 14:59:21
【问题描述】:
我正在尝试让 postgres 数据库与 django 安装对话。
我已按照此处的步骤详细信息:http://blog.iiilx.com/programming/how-to-install-postgres-on-ubuntu-for-django/
但是,当我使用 syncdb 让 django 更新我的 postgres 数据库时,我收到以下错误:
connection_factory=connection_factory, async=async)
django.db.utils.OperationalError: FATAL: database "/home/flowcore/django_db"
does not exist
django_db 是数据库的名称,它确实存在,但在 /home/flowcore/django_db 中当然不存在(这不是 postgres 存储数据的地方!)
settings.py 中的数据库字典如下所示:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.path.join(BASE_DIR, 'django_db'),
'USER': 'django_login',
'PASSWORD': 'mypasswordhere', #obviously i've replaced this with my actual password
'HOST': 'localhost',
}
}
我是否必须指定我的 postgres 数据库文件的绝对路径,如果需要,这些文件存储在哪里?
【问题讨论】:
-
您应该在 settings.py 中显示 DATABASES 字典。
-
您不需要路径。只是名字。 (“django_db”,我猜)
-
@DanielRoseman 完成,我已将其添加到原始问题中:)
-
@wildplasser 我刚刚在上面添加了我的setting.py - 你可以看到它已经指向了。
-
不,那行有一个
os.path.join()。 (不知道应该怎么做)
标签: python django postgresql ubuntu installation