On Jan 12, 10:22 am, bruno desthuilliers
<bruno.desthuilli...@gmail.com> wrote:
> On 11 jan, 18:46, Jo <spaceout...@gmail.com> wrote:
>
> > While building a website using template inheritance one usually does
> > the following:
>
> > fetch from database
> > fetch from some more data from database
> > ... << more required computations
> > then at the end render the template with the fetched data
>
> > Without template inheritance one usually does the following:
>
> > fetch from database
> > render this part of the site with this fetched data
> > fetch some more data from the database
> > render this other part of the site with the fetched data
>
> This has nothing (or very few) to do with inheritance. You'd have the
> same behaviour (ie : first getting all data, then building html, then
> return the response) without using inheritance in your template.

Yes but template inheritance usually leads to this design.

> > Is there a way to get the best of both
> > worlds? Maybe using generators? Thank you.
>
> You can of course pass an iterable to your reponse object (read the
> doc for the HttpResponse object), but then you'll have to organize
> your code very differently, and not necessarily in the most readable
> and maintainable way.
>
> As far as I'm concerned, I'd first try to profile and possibly
> optimize the "very long computation" part.

Yes but you'd have to agree that there is a loss. It would be nice to
render data as it comes. Instead of waiting for all the computation to
finish.
--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to