Skip to content

9nix00/django-qiniu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django qiniu

qiniu file(image) upload helper utils for Django

Requirements

those packages will auto install when install django_qiniu use pip.

Install

pip install django-qiniu

Config

  1. add account_helper.middleware.CurrentUserMiddleware in MIDDLEWARE_CLASSES
  2. set qiniu config follow qiniu-storage document Configurations.
  3. edit settings.py.
DEFAULT_FILE_STORAGE = 'django_qiniu.backends.QiniuStorage'

QINIU_PREVIEW_EXPIRE = 300         # 300 seconds,default is 3600 if not set

How to use

feature 1: simple upload progress

edit your models file.

from django_qiniu.utils import user_upload_dir


# ...fields definition...

pic_00 = models.ImageField('picture 00', upload_to=user_upload_dir, blank=True)

feature 2: show qiniu image easily. by default, we use weui as default our theme. so default size is 75x75

{% load qiniu_helper %}
<li class="weui_uploader_file" style="background:url({% qiniu_preview image_url %})"></li>
{# set width,height and scale #}
<li class="weui_uploader_file" style="background:url({% qiniu_preview image_url width=80 height=90 scale=False %})"></li>
{# disable add domain-url when request %}
<li class="weui_uploader_file" style="background:url({% qiniu_preview image_url width=80 height=90 domain=False %})"></li>
{# auto scale %}
<li class="weui_uploader_file" style="background:url({% qiniu_preview image_url width='auto' height=90 %})"></li>

About

qiniu file(image) upload helper utils

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages