繁体   English   中英

无法在其Heroku postgres数据库上同步Django应用程序的数据库

[英]Cannot sync database for Django app on its Heroku postgres database

我正试图将我的postgres数据库迁移到用于Django应用程序的Heroku中。 在我的settings.py文件中,按照Heroku教程的要求,我有以下内容:

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

但是,当我运行heroku run python manage.py syncdb ,出现以下错误:

django.db.utils.OperationalError: could not connect to server: Connection refused
    Is the server running on host "localhost" (127.0.0.1) and accepting
    TCP/IP connections on port 5432?

我想念什么? 提前致谢!

因此,事实证明问题出在我的项目的设置文件夹中,还有另一个名为local.py的文件。 树如下:

├── microblog
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── settings
│   │   ├── base.py
│   │   ├── base.pyc
│   │   ├── __init__.py
│   │   ├── __init__.pyc
│   │   ├── local.py
│   │   └── local.pyc
│   ├── settings.pyc
│   ├── urls.py
│   ├── urls.pyc
│   ├── wsgi.py
│   └── wsgi.pyc
├── Procfile
└── requirements.txt

由于我遵循的是Django教程入门,因此我的local.py文件中包含以下内容:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'USER': '<user>',
        'PASSWORD': '<pwd>',
        'NAME': '<name>',
        'HOST': 'localhost',
    }
}

那就是问题所在。 我尝试将文件添加到.gitignore中,但这没有用。 解决方案是将这些行实际注释掉。

我有同样的问题。 评论local_settings内容即可解决。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM