Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 无法在其Heroku postgres数据库上同步Django应用程序的数据库_Python_Django_Postgresql_Heroku - Fatal编程技术网

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

Python 无法在其Heroku postgres数据库上同步Django应用程序的数据库,python,django,postgresql,heroku,Python,Django,Postgresql,Heroku,我正在尝试将我的postgres数据库迁移到Heroku,以用于django应用程序。在我的settings.py文件中,按照Heroku教程的指示,我有以下内容: import dj_database_url DATABASES = {'default': dj_database_url.config()} 但是,当我运行heroku run python manage.py syncdb时,会出现以下错误: django.db.utils.OperationalError: could n

我正在尝试将我的postgres数据库迁移到Heroku,以用于django应用程序。在我的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',
    }
}
数据库={
“默认值”:{
“引擎”:“django.db.backends.postgresql_psycopg2”,
“用户”:“,
“密码”:“,
“姓名”:“,
'主机':'本地主机',
}
}

这就是问题的根源。我尝试将该文件添加到我的.gitignore中,但没有成功。解决办法是实际注释掉这些行

我也有同样的问题。注释
local\u settings
content解决了这个问题。

如果是,建议使用
DATABASES['default']=dj\u database\u url.config()
。您已经完全替换了
数据库
字典;他们只是增加了一把新钥匙。这可能不是问题所在,但值得检查。另外,请确保您已经
git commit
ted和
git push
ed将您的最新代码发送给Heroku。嘿,Alex,谢谢您的帮助。然而,事实证明,我的设置目录中有另一个文件把事情搞砸了。说出来让一切都顺利!