django - Heroku django项目只读文件系统

标签 django file-upload heroku upload filesystems

我正在heroku上部署django项目,它工作正常,但是在django admin中,当我尝试上传图像时出现错误:

OSError at /admin/blocks/block/add/

[Errno 30] Read-only file system: '/home/goldwedd'

最佳答案

这是设计使然。

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:

  • 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 支持的任何其他存储后端上执行此操作。 .

关于django - Heroku django项目只读文件系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17716055/

相关文章:

python - 如何创建 django 子类别

php - laravel 5.2 中的输入文件?

c# - 文件上传安全问题

git - 如何完全替换git存储库中的代码

python - django - 将参数从模板传递到 models.py 的函数

python - 独立使用 Django ORM

python - 如何识别内网电脑?

php mysql 图片显示不正确

node.js - 应该使用哪个 mailgun 库将 Parse 托管应用程序迁移到 Heroku?

java - 在部署在 heroku 上的 Web 应用程序中使用 Java Sound API