Wednesday, February 27, 2013

Re: StreamingHttpResponse into a Template

On 2013-02-27, at 18:23 , Stefano Tranquillini wrote:
> Django 1.5 is just came out and it ships the StreamingHttpResponse.
> What i want to do is to print the output of a stream response into a
> template

I'm pretty sure that doesn't make sense: the template has to be
rendered, and I'm pretty sure a given Django template doesn't render to
a stream given is still

What you *can* do is work the other way around, create a
StreamingHttpResponse and fill it with multiple renderings of a template.

> , having for example a bar that grows based on the streamed data
> (something similar to a loading bar).

If your render target is HTML, that doesn't make any sense either.
That's just not how HTML works. You might be able to send a CSS
stream with incremental rules overwriting one another and growing
a "loading bar", but that's abuse of the whole thing and not of
much use.

> so far i've found a solution that basically is to write the pieces of the
> final html page into the generator function, so each yield does a
> render_to_text of a piece of the final html page (i splitted it manually)
> putting each time the data just processed.
> The problem of this solution is that i can't have the loading bar. What I'm
> able to have are incremental data, so i can print out the list of processed
> data, but it's different to what i want to do.
> Is there a way to do what i would like to do?

Think about it again and explain what you're originally trying to
achieve. You seem to be approaching the problem from the wrong
direction, as far as I can read.

You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment