0👍
just to update my experience of this.
so in the end i spent most of my time scratching my head with jquery mobile. of course if i had rtfm’d beforehand i would have probably had a smaller headache out of it all! basically the ajax page updates were just plain annoying, so the important thing here would be to disable them using rel="external"
or data-ajax="false"
on my html form
– and, because of the way #’s are used, you will also want to add these tags to any pages that load up this page also (otherwise the multipage won’t work properly).
i then created a multipage jqm page and link to it via my submit button (in my case with data-rel="dialog"
), with the second page with an empty iframe
; i set the form target
to this iframe and voila! it works! the streaming result from the form submission shows up as it should.
so to sum it up:
- django HttpResponse is returned, where its argument is a generator object. this enables the streaming nature of the output.
-
create the jqm page:
<div id="main" data-role="page"> <div data-role="content"> <form id="myform" method="post" target="response-iframe" action="***django generator page***" data-ajax="false"> ... <a id="submit-button" href="#secondary" data-rel="dialog" data-role="button" data-theme="e">Submit</a> <script> $('#submit-button').live( 'click', function(){ $('#port-form').submit() }) </script> </form> </div> </div> <div id="secondary" data-role="page"> <div data-role="content"> <iframe id="response-iframe"></iframe> </div> </div>
0👍
You can poll Django for progress updates using usual AJAX requests.
It don’t solve the jquery mobile and long polling problem, but it gives you flexibility needed to put your long running task away from the frontend and into the backend (for example using Celery).
To maintain performance I recommend updating status from the long running task to a memcached instance.
In your view just fetch the progress and return i.e. which will fire the dialog box or update some div. Better yet – just the results.
- [Django]-Django global filter
- [Django]-Bin/python3: cannot execute binary file: Exec format error
- [Django]-How to combine select_related() and value()?
- [Django]-Django / MySQL: How to do Autonomous Transactions (commit only sub-set of queries)?
- [Django]-How do I programmatically create a user with django_social_auth?