阿里云OSS2的一个简单的Django存储后端。
django-aliyun-oss2的Python项目详细描述
Django Aliyun OSS2
django存储aliyun OSS
功能
- 阿里云OSS的Django文件存储
- 阿里云OSS的Django静态文件存储
- 在Python3+中工作
安装
$ pip install django-aliyun-oss2
配置
在settings.py
文件中放入以下配置:
ACCESS_KEY_ID="<your access key id>"ACCESS_KEY_SECRET="<your access key secret>"# The URL of AliCloud OSS endpoint# Refer https://www.alibabacloud.com/help/zh/doc-detail/31837.htm for OSS Region & EndpointEND_POINT="<your access endpoint>"BUCKET_NAME="<your bucket name>"# if not exist in aliyun oss platform, it will created automaticallyALIYUN_OSS_CNAME=""# custom domain. optionalBUCKET_ACL_TYPE="private"# bucket access type. available value: private, public-read, public-read-writeALIYUN_OSS_HTTPS=False# optional config. determine use https or not. if not declare, this value will be False by default.# storage media fileDEFAULT_FILE_STORAGE='django_aliyun_oss2.backends.AliyunMediaStorage'# storage static fileSTATICFILES_STORAGE='django_aliyun_oss2.backends.AliyunStaticStorage'
用法
所有静态文件存储设置都可用于静态文件存储。
# The default location for your static filesSTATIC_URL='/static/'
运行以下命令收集每个应用程序的所有子文件夹static
,并上载到静态URL:
$ python manage.py collectstatic
许可证
麻省理工学院许可证