On Wed, 2007-07-04 at 22:52 +0000, Steve Bergman wrote: > I am working on a report generator which needs to render potentially > huge sets of data into an html table. > > The method that generates the rows is an iterator. I believe that if > I do something like: > > return HttpResponse(my_iterator()) > > it will do what I want. Except that I want to do it with a template. > > I can do something like: > > return render_to_response('report.html', > dict(output=generate_output())) > > and it works, but it does all the rendering before it starts sending > to the browser, incurring the potentially large memory requirements of > doing so.
That's correct. Templates render to a string and that string is passed upstream. If you search the archives, you'll see that we recently tried to switch to iterative rendering and a lot of unintended side-effects showed up. So that is being worked on a bit more before we try again. Note also, that a lot of middleware will interfere with your intentions here: any middleware that needs to examine the content to do its work as part of process_response() is going to have to convert the iterator to a string, so you'll need to be careful in your configuration. Regards, Malcolm -- Quantum mechanics: the dreams stuff is made of. http://www.pointy-stick.com/blog/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---