这是django教程: gettingstartedwithdjango/en/lessons/introduction-and-launch/
我遇到的问题是最后一次打电话给heroku:
heroku python manage.py syncdb
这是我得到的错误:
(blog-venv)vagrant @ precise64:/ vagrant / projects / microblog $ heroku run python manage.py syncdb 运行`python manage.py syncdb`附加到终端... up.2530 追溯(最近的最后一次调用):文件manage.py,第10行,< module> execute_from_command_line(sys.argv)文件/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py,第443行,在execute_from_command_line utility.execute()文件/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py,第382行,执行 self.fetch_command(subcommand).run_from_argv(self.argv)文件/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py ,第196行,在run_from_argv self.execute(* args,** options .__ dict__)文件/app/.heroku/python/lib/python2.7/site-packages/django/core /management/base.py,第232行,执行 output = self.handle(* args,** options)文件/app/.heroku/python/lib/python2.7/ site-packages / django / core / management / base.py,第371行,处理 return self.handle_noargs(** options)文件/app/.heroku/python/lib/python2 .7 / site-packages / django / core / management / commands / syncdb.py,第57行,在handle_noargs cursor = connection.cursor()文件/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/__init__.py,第306行,在光标 cursor = self.make_debug_cursor(self._cursor())文件/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2 /base.py,第177行,_cursor self.connection = Database.connect(** conn_params)文件/app/.heroku/python/lib/python2.7/site-packages /psycopg2/__init__.py,第178行,连接 return _connect(dsn,connection_factory = connection_factory,async = async) psycopg2.OperationalError:无法连接到服务器:没有这样的文件或目录服务器是否在本地运行,并在Unix域套接字/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看到正确的数据库设置。然后syncdb工作正常
DATABASES = {'default':dj_database_url.config()}
I worked my way through a great django tutorial online, but am having an issue with the final heroku deployment.
Here is the django tutorial: gettingstartedwithdjango/en/lessons/introduction-and-launch/
The issue I have is with the last call to heroku:
heroku python manage.py syncdb
Here is the error I get:
(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$Any thoughts
解决方案As far as I know ( git intermediate level knowledge ) If you forgot to add locals.py to the .gitignore file and committed it then the git repository will have the locals.py file still in it .
You have to remove the file from git repository since it was included in previous commits.
git rm --cached microblog/settings/local.pyThen add microblog/settings/local.py to .gitignore and commit the changes.
Once heroku sees the correct DATABASES setting . Then syncdb works fine
DATABASES = {'default' : dj_database_url.config() }
更多推荐
GSWD Heroku Django manage.py问题
发布评论