【发布时间】:2017-04-10 15:02:04
【问题描述】:
据我所知,跑步时 $heroku 运行 python manage.py 迁移
它从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
我试图在没有应用名称的情况下运行“python manage.py migrate”,但结果是一样的。在推送到 git 之前,我在本地机器上运行“makemigrations”。我还能够创建超级用户,我可以打开 https://my-app-name.herokuapp.com/admin 并向 db 添加一些数据,但我的应用看不到这些数据。
有什么建议吗?我现在已经坚持了 3 天,所以我将不胜感激。
附:我使用带有 postgis 扩展的 heroku postgresql hobby-basic。
附言
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路径。 -
Daniel Roseman,如果有帮助,我刚刚将此信息添加到问题中。
-
@shongololo 因为我是 heroku 的新手,所以我想知道我是否做对了。我使用了命令: SET search_path TO findCharge_chargepoints,public;但无论如何,当我试图对表做某事时,我得到了错误:表“findcharge_chargepoints”不存在。
标签: python django postgresql heroku postgis