Django Uploader uses jQuery file upload to allow drag-and-drop file upload of any file type in the Django Admin.
Project description
What it does
Django Uploader uses jQuery file upload to allow drag-and-drop file upload of any file type in the Django Admin. Third-party applications to write handlers for specific file types, and register them with Django Uploader. When a file of that type is uploaded, it passes the information to the handler so that it can make a new record with that file.
Installation
Installation is easy using pip.
pip install django-uploader
Add uploader to your INSTALLED_APPS setting.
Write one or more upload handlers.
Go to /admin/uploader/upload/ to start uploading.
Writing an upload handler
An upload handler assigns one or more MIME types to a function. There should only be one handler for a given MIME type, although Uploader does allow some overlap using ‘*’. For example, you can have one handler that handles image/tiff and another that handles image/* and yet another that handles */*. The image/tiff handler would get any .tiff images, the image/* would get any other type of image and the */* handler would get any other type of file.
To start, create a file named upload.py in your application. This file can contain several different handlers. When the Uploader application is first loaded, it attempts to import this file from every installed application.
A basic handler looks like this:
from uploader.registration import upload_handlers def photo_handler(obj): """ Handle the creation of a SimpleModel record from an uploaded image. """ from .models import SimpleModel new_item = SimpleModel.objects.create( name=obj.filename, slug=obj.filename_slug, description='', file=obj.file_contents ) return new_item photo_handler.thumbnail_attribute = 'thumb' upload_handlers.register(['image/jpeg', 'image/png'], photo_handler)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-uploader-0.1.tar.gz
.
File metadata
- Download URL: django-uploader-0.1.tar.gz
- Upload date:
- Size: 793.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba816b7738a7109c89ef1fa5980ccbf1fdedaa4ea45291d05be3911ece575463 |
|
MD5 | 55cc326bbe6d5e01da33be72498a7355 |
|
BLAKE2b-256 | a7e5afcf6f5b1c0d3530f4bc3258b9cddd8cf7ed836b51dac9951d47f0ab718c |