我正在设置一个新的开发环境,遵循 django 设置教程并遇到问题。这是我尝试运行syncdb时得到的
Running `python doccal/manage.py syncdb` attached to terminal... up, run.1
Traceback (most recent call last):
File "doccal/manage.py", line 14, in <module>
execute_manager(settings)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__i
nit__.py", line 459, in execute_manager
utility.execute()
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__i
nit__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/bas
e.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/bas
e.py", line 232, in execute
output = self.handle(*args, **options)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/bas
e.py", line 371, in handle
return self.handle_noargs(**options)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/com
mands/syncdb.py", line 57, in handle_noargs
cursor = connection.cursor()
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/__init_
_.py", line 306, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/postgre
sql_psycopg2/base.py", line 177, in _cursor
self.connection = Database.connect(**conn_params)
File "/app/.heroku/venv/lib/python2.7/site-packages/psycopg2/__init__.py", lin
e 179, in connect
connection_factory=connection_factory, async=async)
psycopg2.OperationalError: could not connect to server: No such file or director
y
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
在使用相同的步骤之前,我已经设置了相同的项目并且从未遇到过问题。几周前,我确实收到了一封电子邮件,说 Heroku 正在从共享数据库中迁移出来,并假设这以某种方式涉及。
另外,我确实注意到教程中有两个新步骤,即安装 dj-database-url 并将这些行添加到 settings.py
import dj_database_url
DATABASES = {'default': dj_database_url.config(default='postgres://localhost')}
我试图在有和没有这些行的情况下运行它,无论如何都会遇到同样的问题。
另一篇文章建议修复是这样做
heroku addons:add shared-database
试过了,得到一条消息,共享数据库已被弃用并使用 heroku-postgresql,但这没有效果。
谢谢你的帮助