Django的数据没有被带到heroku

3zwtqj6y  于 2022-11-24  发布在  Go
关注(0)|答案(2)|浏览(92)

我有Django应用程序,其中包括用户和帖子模型。这些应用程序在本地进行迁移和迁移后运行得很好。我尝试了两种不同的方法来部署这些应用程序到Heroku。首先,使用Heroku Git,这些应用程序在Heroku上的运行方式与在本地相同。
When using GitHub, however, all data were not brought to Heroku. I tried to run "python manage.py makemigrations" and "python manage.py migrate" on Heroku, but the data from local was not brought still.
如果你能解释并帮助解决使用GitHub的问题,我将非常感激。

qzlgjiam

qzlgjiam1#

我认为你也必须在Heroku上迁移,尝试:

heroku run python manage.py migrate

请参阅heroku docs

kcwpcxri

kcwpcxri2#

检查您.gitignore文件,可能是gitignore文件中的db.sqlite,您可以将其删除;另一个选项是转储数据并在生产中加载,您可以运行

python3 manage.py dumpdata > data.json

和加载数据

python3 manage.py loaddata data.json

相关问题