Download multiple files using Django

How to upload multiple files in Django?

+4
source share
2 answers

After a lot of pain, I ended up getting the add-on ( http://www.uploadify.com/ ) while working with django, but the problem was not really django, but getting it to work with the Apple Mac; browsers on this platform do not serve cookies from Flash; you need to install them manually:

Therefore, I include them in my render answer:

return render_to_response('files_upload.html', { 'session_cookie_name': settings.SESSION_COOKIE_NAME, 'session_key': request.session.session_key 

And submit them from the download via the configuration specified in the template:

 $(document).ready(function() { $('#fileInput').uploadify({ 'scriptData': {'{{session_cookie_name}}': '{{session_key}}'}, 

I saw how this improved with the help of a decorator over the view, but it was a dirty hack that I used in the middleware to copy the POST to COOKIE before the session middleware did the session restore.

 class FakeUploadCookieMiddleware(object): """TODO: replace the hardcoded url '/upload' with a 'reverse'.""" def process_request(self, request): if request.path == '/upload/' \ and request.POST.has_key(settings.SESSION_COOKIE_NAME): request.COOKIES[settings.SESSION_COOKIE_NAME] = \ request.POST[settings.SESSION_COOKIE_NAME] logging.debug('Faking the session cookie for an upload: %s', \ request.POST[settings.SESSION_COOKIE_NAME]) 
+11
source

Someone has already created a field for multiple downloads that can serve your purpose.

http://scompt.com/archives/2007/11/03/multiple-file-uploads-in-django

Django has excellent support for creating forms and working with file uploads. I would read these articles to better understand how the multi-user field code works.

+2
source

All Articles