据我所知运行 $ 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