一段时间后,Heroku上的Django应用会删除对象 [英] Django app on Heroku deletes objects after some time

查看:65
本文介绍了一段时间后,Heroku上的Django应用会删除对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个简单的Django Q& A论坛应用程序,并将其部署在Heroku上.该站点的本地版本运行良好.但是,正式版不会将问题,答案等存储超过几个小时.

我决定坚持使用Django随附的sqlite3.我不希望网站有太多流量,所以我决定现在保留开发数据库是值得的.

站点: http://immense-plateau-35286.herokuapp.com

我已经在Heroku的数据库设置页面上尝试了一些解决方案,但到目前为止还没有成功.

知道这可能是什么吗?

解决方案

Heroku的文件系统是短暂的.只要您的dyno重新启动,经常发生,您写给它的任何内容都会丢失.由于SQLite将数据存储在文件系统上的文件中,因此在Heroku上不是一个好选择.

相反,请考虑使用Heroku支持的许多客户端-服务器数据存储之一. 其PostgreSQL产品运作良好.

I've written a simple Django Q&A forum app and deployed it on Heroku. The local version of the site works fine. However, the production version does not store the questions, answers etc. for more than a few hours.

I decided to stick with sqlite3 that comes with Django. I don't expect a lot of traffic to the site so I decided it would be worth it to keep the development database for now.

site: http://immense-plateau-35286.herokuapp.com

I've tried a few solutions from the DB setup page on Heroku, but have not had any success so far.

Any idea what this might be?

解决方案

Heroku's filesystem is ephemeral. Anything you write to it will be lost anytime your dyno restarts, which happens frequently. Since SQLite stores its data in a file on the filesystem it isn't a good choice on Heroku.

Instead, consider using one of the many client-server data stores that Heroku supports. Its PostgreSQL offering works reasonably well.

这篇关于一段时间后,Heroku上的Django应用会删除对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆