-
Notifications
You must be signed in to change notification settings - Fork 49
Home
A Django re-usable app to integrate Uploadify.
- Download django-uploadify
- Place the folder ‘uploadify’ somewhere on your Python path (either in your project directory or inside of Python26\Lib\site-packages\).
- Add ‘uploadify’ to your INSTALLED_APPS in your project’s settings.py file
- Add a reference to uploadify in your urls.py…
(r'^uploadify/', include('uploadify.urls')),
- Download uploadify
- Copy all of the ‘uploadify’ folder from the Uploadify distribution into your media root. Default is: MEDIA_ROOT\js\uploadify\
- Rename the uploadify file from “jquery.uploadify.v2.1.0.min.js” (or whatever version it is) to simply “jquery.uploadify.js”
- In uploadify/settings.py, make sure the setting UPLOADIFY_ROOT is set to the correct value if the uploadify folder is installed to a location other than the default. Note that the UPLOADIFY_ROOT setting is relative to the MEDIA_ROOT value.
Django-uploadify works by providing a template tag, {% multi_file_upload %}., which takes a single parameter. The template tag will render the Uploadify jquery/flash multi-file upload interface on the page. A user may operate Uploadify, selecting and uploading multiple files. For each file that is uploaded a Django signal will be fired, containing the file data. After all uploads have been completed, the template tag will use the value of ‘upload_complete_url’. It will fetch that page via AJAX, and replace the Uploadify GUI with the contents of the page (a jQuery $.load).
To insert the django-uploadify template tag…
{% load uploadify_tags }{ multi_file_upload ‘/your/url/upload/complete/’ %}
Creating a signal receiver…
def upload_received_handler(sender, data, **kwargs):
if file:
//# process the received file here
print data.fileupload_recieved.connect(upload_received_handler, dispatch_uid=‘yourapp.whatever.upload_received’)
Provides the following arguments:
- data – A django file, the value of
request.FILES['Filedata']
When this page is fetched by the client-side javascript, the following Uploadify values are POST’ed to it:
- filesUploaded – The total number of files uploaded
- errors – The total number of errors while uploading
- allBytesLoaded – The total number of bytes uploaded
- speed – The average speed of all uploaded files