Git Product home page Git Product logo

django-qiniu's Introduction

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>

django-qiniu's People

Contributors

9nix00 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

manlan2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.