How can I flush my response stream in django?
One of my response content was build by several synchronous method, how can I flush my response to client browser as soon as some part of the response content is ready? Most Http response object(both java and .net) has a method flush() to do so . But django's HttpResponse's flush method does nothing : def flush(self): pass --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: How can I flush my response stream in django?
On Aug 24 2007, 8:18 pm, "Jeremy Dunck" wrote: On 8/24/07, whitesmell wrote: > One of my response content was build by several synchronous method, > how can Iflushmy response to client browser as soon as some part of > the response content is ready? The HttpResponse constructor takes either a string or an iterable. To trickle content down, you can make the iterable a generator. To reopen a really old thread: For performance reasons it might be a good idea to start sending HTML to the client before the whole page has been rendered. For instance, flushing directly after makes sure new HTTP requests to linked media (CSS and JS) gets requested while the rest of the page is loaded. Now: Is there a nice way of doing this in Django? -- Emil Stenström http://friendlybit.com -- 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.
Re: How can I flush my response stream in django?
On Wed, Oct 6, 2010 at 3:58 PM, Emil Stenström wrote: > On Aug 24 2007, 8:18 pm, "Jeremy Dunck" wrote: >> >> On 8/24/07, whitesmell wrote: >> > One of my response content was build by several synchronous method, >> > how can Iflushmy response to client browser as soon as some part of >> > the response content is ready? >> >> The HttpResponse constructor takes either a string or an iterable. >> >> To trickle content down, you can make the iterable a generator. > > To reopen a really old thread: > > For performance reasons it might be a good idea to start sending HTML > to the client before the whole page has been rendered. For instance, > flushing directly after makes sure new HTTP requests to linked > media (CSS and JS) gets requested while the rest of the page is > loaded. > > Now: Is there a nice way of doing this in Django? Short answer: it's not well-supported. There are middleware which require access to the whole content (CSRF (possibly fixed now), GZip, etc.) I think people in Django core would like to better support it, but it's not an easy problem, because post-request cleanup depends on some signalling based on the response being complete. Please post to Django-dev if you'd like to discuss improving support. Related tickets: http://code.djangoproject.com/ticket/7581 http://code.djangoproject.com/ticket/13910 -- 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.
Re: How can I flush my response stream in django?
On 8/24/07, whitesmell <[EMAIL PROTECTED]> wrote: > > One of my response content was build by several synchronous method, > how can I flush my response to client browser as soon as some part of > the response content is ready? > > Most Http response object(both java and .net) has a method flush() to > do so . But django's HttpResponse's flush method does nothing : The HttpResponse constructor takes either a string or an iterable. To trickle content down, you can make the iterable a generator. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---