簡體   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