據我所知運行 $ Heroku的執行python manage.py遷移的Heroku + Django的migrate命令不會創建任何表
從models.py創建所有表時。但是我的輸出看起來不一樣:表格沒有創建,甚至沒有提到。
Operations to perform:
Apply all migrations: findCharge
Running migrations:
Applying findCharge.0001_initial... OK
Applying findCharge.0002_auto_20161124_1729... OK
Applying findCharge.0003_auto_20161124_1955... OK
Applying findCharge.0004_chargepoints_description... OK
反正當我打電話
$ heroku pg:psql and then ONYX=> \dt
它看起來像創建表和關係列表「findCharge_chargepoints」。
…
public | findCharge_chargepoints | table | owner_name
…
但是當我鍵入
ONYX=> SELECT * FROM findCharge_chargepoints;
ERROR: relation "findcharge_chargepoints" does not exist
我試圖不應用程序名稱運行「蟒蛇manage.py遷移」,但結果是一樣的。在推送到git之前,我在本地機器上運行「makemigrations」。我也能創建超級用戶,我可以打開https://my-app-name.herokuapp.com/admin並添加一些數據到數據庫,但我的應用程序不會看到這些數據。
有什麼建議嗎?我現在堅持3天,所以我會很感激任何幫助。
P.S.我使用heroku postgresql hobby-basic和postgis擴展。
P.P.S.從settings.py
數據庫設置:
DATABASES = {
'default':{
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'charging_points',
'USER': 'postgres',
'PASSWORD': 'XXX',
}
}
,並在文件
import dj_database_url
DATABASES['default'] = dj_database_url.config()
DATABASES['default']['ENGINE'] = "django.contrib.gis.db.backends.postgis"
可以顯示數據庫設置嗎? –
如果它不使用默認的'公共'模式,那麼你可能還必須提供完整的'schema.table'路徑。 – shongololo
丹尼爾羅斯曼,我剛剛添加這個信息的問題,如果它可以幫助。 – sHalnes