The handling of the POST request is typical. I don't know what your model class looks like, but the ???? could look something like this:
form = UploadForm(request.POST, request.FILES) if form.is_valid(): instance = ModelClassWithFileField() instance.uploaded_by = request.user save_instance(form, instance) request.user.message_set.create(message=_('Your file has been received.')) That's it. The progress magic really happens in the code from the snippets you listed: the upload handler that tracks progress in the cache, and the view that reports it. Your template's going to need some JavaScript, too, of course, to get the progress reports and update the page. I think that's all it took for me. Make sure you've got the latest version of the 2070 patch ... and make sure you've got a caching mechanism configured; forgetting to start memcached on your dev box after a reboot can cause some head-scratching. ;^) John On May 2, 2008, at 11:40 PM, Julien wrote: > > Hi everyone, > > I'm trying to use patch with ticket #2070 [1] to be able to upload big > files and have a progress bar, and I can't quite figure out how to > make it work... > > I'm also using 2 snippets [2] and [3]. Then, here's my simple view and > template: > > View > ------- > > def frontpage(request): > if request.method == 'POST': > # [????] I don't know what to put there!... > else: > form = UploadForm() > > return render_to_response('frontpage.html', > { 'form': form }, > > context_instance=RequestContext(request)) > > Template > ------------- > > [insert javascript from snippet [3] here] > > <FORM action="." > enctype="multipart/form-data" > method="post"> > {{ form }} > <INPUT type="submit" value="Send"> > </FORM> > > > Settings > ----------- > from django.conf import global_settings > FILE_UPLOAD_HANDLERS = > ('upload.upload_handler.UploadProgressCachedHandler', ) + > global_settings.FILE_UPLOAD_HANDLERS > > The form just contains a file input. When I press submit, I enter the > view again but I don't know what code to put in that view to replace > the [????] thing above. Should that code wait for the end of the > upload before returning anything, and if so, how? > > I couldn't find any help on the ticket page or on this mailing list. > Can you see what I'm missing to make it work? > > Many thanks! > > Julien > > > [1] http://code.djangoproject.com/ticket/2070 > [2] http://www.djangosnippets.org/snippets/678/ > [3] http://www.djangosnippets.org/snippets/679/ > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---