我正在尝试在Heroku上创建一个Django应用程序,详见Heroku / Django Cedar堆栈教程。
我已经达到了在Heroku上部署代码的程度,但是当我运行heroku run python appname/manage.py syncdb
时,我得到以下跟踪:
Traceback (most recent call last):
File "planamo/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/__init__.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/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/core/management/commands/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 308, in cursor
cursor = util.CursorWrapper(self._cursor(), self)
File "/app/.heroku/venv/lib/python2.7/site-packages/django/db/backends/postgresql_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", line 179, in connect
connection_factory=connection_factory, async=async)
psycopg2.OperationalError: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
我不知道问题是什么。发生了什么事?
答案 0 :(得分:3)
回答了我自己的问题:你必须运行heroku addons:add shared-database
答案 1 :(得分:2)
我刚发现了这个错误的另一个原因。 Heroku在settings.py文件的末尾注入代码。
如果settings.py的最后一行不包含进位返回注入代码,则可以忽略。
的情况答案 2 :(得分:0)
您可以尝试在settings.py中的数据库配置中添加:'HOST':'127.0.0.1'