Django app on Heroku deletes objects after some time(Heroku 上的 Django 应用程序会在一段时间后删除对象)
问题描述
我编写了一个简单的 Django 问答论坛应用程序并将其部署在 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 应用程序会在一段时间后删除对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Heroku 上的 Django 应用程序会在一段时间后删除对象
基础教程推荐
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 在 SQL 中连接多个表 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 无法解决整理冲突 2021-01-01
