deeru七牛插件
Project description
DeerU七牛插件
安装
pip install deeru-qiniu
使用
运行初始化命令
python manage.py init_qiniu根据提示进行配置, 你也可以跳过此步,在admin的 “配置” 中添加名为 “七牛配置” 的配置,配置内容为:
{ 'access_key': 'access_key', 'secret_key': 'secret_key', 'bucket_name': '空间名', 'media_pre':'媒体文件前缀(可为空)', 'static_pre': '静态文件前缀(可为空)' }或是在 settings_local.py 中添加如下配置:
QINIU = { 'access_key': 'access_key', 'secret_key': 'secret_key', 'bucket_name': '空间名', 'media_pre':'媒体文件前缀(可为空)', 'static_pre': '静态文件前缀(可为空)' }修改settings
在 settings_local.py 的 CUSTOM_APPS 中添加app, 修改或添加 STATIC_URL 、 MEDIA_URL 内容为七牛的域名,如果你设置了前缀,需要加上前缀
CUSTOM_APPS = [ 'deeru_qiniu.apps.DeeruQiniuConfig' ] STATIC_URL='http://xx.bkt.clouddn.com/你的前缀/' MEDIA_URL='http://xx.bkt.clouddn.com/你的前缀/'上传文件
运行命令上传文件
# 上传媒体文件 python manage.py upload_qiniu --type media # 上传静态文件,上传静态文件前先运行collectstatic命令 python manage.py collectstatic python manage.py upload_qiniu --type static若有相同名字的文件会上传失败,可用删除命令删除之前上传的文件
命令
删除命令
会删除所有媒体文件或静态文件,不支持单个文件删除,删除单个文件在七牛后台中自行删除
# 上传媒体文件
python manage.py delete_qiniu [--type (media|static) ]
配置说明
media_pre ,static_pre
url的前缀,可为空,建议设置防止与空间中的旧文件冲突
其他
如果文章中已经插入了图片,代理媒体文件会导致文章中的图片失效,需要重新编辑文章
license
GUN V3.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deeru-qiniu-1.0.0.tar.gz.
File metadata
- Download URL: deeru-qiniu-1.0.0.tar.gz
- Upload date:
- Size: 18.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
036ec19acd2c0979c7d59c702556e47e597b72d8dbb7ab37d24db16d2b398235
|
|
| MD5 |
70040d713ef8a4a4205e5d5baa5bd5ea
|
|
| BLAKE2b-256 |
ef0e3f40acb3e7a5eadbc734fd281cc614c5df932d90458209bf437fde73619e
|
File details
Details for the file deeru_qiniu-1.0.0-py3-none-any.whl.
File metadata
- Download URL: deeru_qiniu-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b1be697acfeb449b9687e24c61dbe13c3f05e54c8aaba934c67e5d9e85fc320
|
|
| MD5 |
9bcf63b14e0f9329cc22ef9af16b691e
|
|
| BLAKE2b-256 |
51b1fe8816a54fdac5ad41cec0bddcbb4a7aea86bdeee4c16f222912fb67be51
|