加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

GSWD Heroku Django manage.py问题

发布时间:2020-12-20 11:25:14 所属栏目:Python 来源:网络整理
导读:我在线学习了一个很棒的 django教程,但是我遇到了最终heroku部署的问题. 这是django教程: http://gettingstartedwithdjango.com/en/lessons/introduction-and-launch/ 我遇到的问题是最后一次调用heroku: heroku python manage.py syncdb 这是我得到的错误
我在线学习了一个很棒的 django教程,但是我遇到了最终heroku部署的问题.

这是django教程:
http://gettingstartedwithdjango.com/en/lessons/introduction-and-launch/

我遇到的问题是最后一次调用heroku:

heroku python manage.py syncdb

这是我得到的错误:

(blog-venv)vagrant@precise64:/vagrant/projects/microblog$heroku run python manage.py syncdb
Running `python manage.py syncdb` attached to terminal... up,run.2530
Traceback (most recent call last):
  File "manage.py",line 10,in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py",line 443,in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/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/python/lib/python2.7/site-packages/django/core/management/base.py",line 196,in run_from_argv
    self.execute(*args,**options.__dict__)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py",line 232,in execute
    output = self.handle(*args,**options)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py",line 371,in handle
    return self.handle_noargs(**options)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/commands/syncdb.py",line 57,in handle_noargs
    cursor = connection.cursor()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/__init__.py",line 306,in cursor
    cursor = self.make_debug_cursor(self._cursor())
  File "/app/.heroku/python/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/python/lib/python2.7/site-packages/psycopg2/__init__.py",line 178,in connect
    return _connect(dsn,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"?

(blog-venv)vagrant@precise64:/vagrant/projects/microblog$

有什么想法吗

解决方法

据我所知(git中级知识)如果你忘了将locals.py添加到.gitignore文件并提交它,那么git存储库中仍会有locals.py文件.

您必须从git存储库中删除该文件,因为它包含在以前的提交中.

git rm --cached microblog/settings/local.py

然后将microblog / settings / local.py添加到.gitignore并提交更改.

一旦heroku看到正确的DATABASES设置.然后syncdb工作正常

DATABASES = {'default' : dj_database_url.config() }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读