Hi, normally in views.py I have a function that takes a request and returns a render_to_response or the like. I, however, would like it to take a request and have Django reply with multiple responses. Is there a way to do this, or is this not possible with HTTP anyway?
What I am trying to achieve: Have a a view that gets called and in it I have a JS/AJAX script that asks for some data. However, calculating the data takes a while and it comes one after the other. So I thought that I could send the data as soon as it becomes available. In my example I have a graph (using flot) and it would also look natural to have the data points show up one by one. A different approach: Have JS ask for more data (using GET) until the view responses sets a flag (NO_MORE_DATA = True). I don't like this, since for me this looks like it defies the A in AJAX and the view would lose all parameters (I.e. which points it already sent and which not). However, I don't know much JS, nor AJAX nor do I understand the HTTP protocol good enough. Maybe this has been done before? Is there a way of having server-side generated AJAX-actions? Is there a way of having Django send something within a views-function (as opposed to returning it at the end)? Some possible code: def my_view(request): data = MyModel.objects.filter('something').order_by('somethingelse') for item in list(data): # Note, I don't do this but this is just to show how what I want send_json(do_something(item)) # send_json() is the crucial (non-existing) function that I am looking for return None # or maybe return Done or something like it Best regards, Christoph -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.