Heroku-deployed Django webpage doesn't update when DB changes

有些话、适合烂在心里 提交于 2021-02-10 14:42:15

问题


I have deployed an app in Heroku using Django. The Django program uses a SQLite database db.sqlite3 on root directory to populate its page. Separately, there is also a Node.js scraper program that inserts to that database.

The problem is that the hard-refreshed webpage shows the same data even after the content of the database changed. Curiously, this does not happen when it is tested locally with python manage.py runserver. How can I fix this problem?

Thank you in advance!


For reference, here is my requirements.txt file:

Django==1.10.6  
gunicorn==19.7.1
Pillow==4.0.0
selenium==3.3.1
whitenoise==3.3.0

回答1:


You cannot use sqlite on Heroku.

An sqlite db is stored as a file on the local filesystem. But in Heroku the filesystem is ephemeral and is not shared between dynos. Every time you redeploy your app, or scale your process, or in your case launch a worker, you get a new filesystem with a different copy of the db file.

Use the proper Postgres support via the add-ons.



来源:https://stackoverflow.com/questions/43379209/heroku-deployed-django-webpage-doesnt-update-when-db-changes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!