Coder Social home page Coder Social logo

adilkhash / django-files-widget Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tnd/django-files-widget

0.0 2.0 0.0 1.59 MB

Django AJAX upload widget and model field for multiple files or images, featuring drag & drop uploading, upload progress bar, sortable image gallery

License: Other

Python 51.31% CSS 5.71% JavaScript 37.31% HTML 5.67%

django-files-widget's Introduction

django-files-widget

Django AJAX form widgets and model fields for multiple files/images upload with progress bar

This is currently an alpha release. Not all functionality is there, only ImageField and ImagesField have been implemented and there is not yet enough error handling.

Features

  • Drag & drop file uploading via AJAX
  • Plus three other ways to add files: upload button, Django Filebrowser library, and by URL
  • Uploading multiple files at once
  • Upload progress bar
  • Four model fields with corresponding form fields and widgets: ImagesField, ImageField, FilesField, and FileField
  • Image gallery widget with drag & drop reordering
  • Documents gallery widget with file type icons with drag & drop reordering
  • Integrates with Django Admin, Grappelli, Django Filebrowser and Mezzanine

Screenshots

File drag & drop to ImagesWidget in Django Admin Ajax upload progress bar in ImagesWidget in Django Admin
File drag & drop to ImagesWidget in Django Admin Ajax upload progress bar in ImagesWidget in Django Admin

Quick Start

Requirements

Install

pip install git+git://github.com/TND/django-files-widget.git

In settings.py

INSTALLED_APPS = (
    ...,
    'sorl.thumbnail',
    'topnotchdev.files_widget',
    ...,
)

MEDIA_URL = ...
MEDIA_ROOT = ...
THUMBNAIL_DEBUG = False

(Optional) basic settings with their defaults:

FILES_WIDGET_TEMP_DIR            # 'temp/files_widget/'
FILES_WIDGET_FILES_DIR           # 'uploads/files_widget/'
FILES_WIDGET_JQUERY_PATH         # (jQuery 1.9.1 from Google)
FILES_WIDGET_JQUERY_UI_PATH      # (jQuery UI 1.10.3 from Google)
FILES_WIDGET_USE_FILEBROWSER     # False
FILES_WIDGET_FILEBROWSER_JS_PATH # 'filebrowser/js/AddFileBrowser.js'

In urls.py

url(r'^files-widget/', include('topnotchdev.files_widget.urls')),

In models.py

from topnotchdev import files_widget

class MyModel(models.Model):
    image = files_widget.ImageField()
    images = files_widget.ImagesField()

Django Auth User Permissions (optional)

files_widget.can_upload_files

Template Usage Examples

No extra steps are required to use the widget in your Admin site. Here are some examples of displaying files and (thumbnail) images on your site:

A list of linked thumbnails:

{% for img in my_instance.images.all %}
    <a src="{{ img.url }}">
        {{ img.thumbnail_tag_100x100 }}
        <span class="caption">{{ img.filename }}</span>
    </a>
{% endfor %}

Only the next image:

{{ my_instance.images.next.img_tag }}

The filename without extension and underscores of the next 3 (or n) images:

{% for img in my_instance.images.next_3 %}
    {{ img.display_name }}
{% endfor %}

Or other attributes:

{{ my_instance.image.url }}
{{ my_instance.image.filename }}
{{ my_instance.image.local_path }} (just as an example)
{{ my_instance.image.exists }}
{{ my_instance.image.get_size }}
{{ my_instance.image.thumbnail_64x64.url }}
...

License

MIT

Credits

API Documentation

(Under construction)

Navigation

Settings

Model Fields

Model Field Options

FilesField and ImagesField Instance Attributes

FileField, FilesField, ImageField and ImagesField Instance Attributes

Django Auth Permissions

Static Files Inclusion

Signals

Signal Handlers

Management Commands

django-files-widget's People

Contributors

altimore avatar cericoda avatar maartenth avatar mionch avatar

Watchers

 avatar  avatar

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.