Heroku django 项目只读文件系统 [英] Heroku django project read-only file system
问题描述
我在 heroku 上部署 django 项目,它工作正常,但是在 django admin 中,当我尝试上传图片时出现错误:
I'm deploying django project on heroku, it works fine, but in django admin, when i'm trying to upload image i got error:
OSError at /admin/blocks/block/add/
[Errno 30] Read-only file system: '/home/goldwedd'
推荐答案
这是设计使然.
您的应用程序被编译成一个 slug 以供 dyno 管理器快速分发.slug 的文件系统是只读的,这意味着您不能动态写入文件系统以进行半永久存储.不支持以下类型的行为:
Your app is compiled into a slug for fast distribution by the dyno manager. The filesystem for the slug is read-only, which means you cannot dynamically write to the filesystem for semi-permanent storage. The following types of behaviors are not supported:
- 在公共目录中缓存页面
- 将上传的资产保存到本地磁盘(例如使用 attachment_fu 或回形针)
- 使用 Ferret 编写全文索引
- 写入文件系统数据库,如 SQLite 或 GDBM
- 为 git-wiki 之类的应用访问 git 存储库
- Caching pages in the public directory
- Saving uploaded assets to local disk (e.g. with attachment_fu or paperclip)
- Writing full-text indexes with Ferret
- Writing to a filesystem database like SQLite or GDBM
- Accessing a git repo for an app like git-wiki
https://devcenter.heroku.com/articles/read-only-filesystem
如果您想上传文件,您需要将文件上传到 S3 或 django-storages.
If you want to upload files, you need to do so to S3 or any of the other storage backends supported by django-storages.
这篇关于Heroku django 项目只读文件系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!