I am trying to use django-progressbarupload app
to add progress bar to my Django app. But it is not working .... The django-progressbarupload app
templates tags are loading fine and also file is uploading to the server but progress bar is not showing up ...and their is no javascript error on the console... I have followed this tutorial
Can anyone tell how to add progress bar to Django app
It's not the best solution (and not so consistent) but it will be the easiest to implement.
Create js file e.g. progress_bar.js
In your admin.py
In progress_bar.js
The idea is to prevent default form submition, create new XMLHttpRequest, inject progressbar with messages and then send the data showing the process.
It is very important to set processData: false, contentType: false, otherwise it will not handle the file in the form
And finaly in your progress_bar.js set event handlers for the progress bar itself.
NOTE: In order not to have html page appearing under the form after success you have to change your view that returns HttpResponse object or simply change the window.location.
The described method should work for any form with django.
It clearly is a bug in webkit based browsers, here's the relevant thread:
Ajax form upload progress bar
Also here is the relevant github issue:
https://github.com/ouhouhsami/django-progressbarupload/issues/2
To comprehend, webkit doesn't allow to make ajax calls while uploading file, the usual workaround is to use dynamically created iframe (mentioned in above SO thread).