django-storage-backends
Installation
SKILL.md
Django Storage Backends(Django 存储后端)
来源:https://docs.djangoproject.com/en/stable/topics/files/、/howto/custom-file-storage/、django-storages S3 docs
用途
统一抽象用户上传文件的存储位置。默认本地 MEDIA_ROOT,可替换为 S3/GCS/Azure 或自定义远程后端;也可用于将 collectstatic 输出到对象存储。
何时使用
- 用户上传文件(
FileField/ImageField)需存到对象存储 - 多环境分别使用不同存储(dev 本地、prod S3)
- 需要自定义路径生成、ACL、CloudFront 签名 URL 等
- 实现自有后端(FTP/某私有协议/加密存储)
基础用法
模型字段
from django.db import models