On 1/9/07, David Cramer <[EMAIL PROTECTED]> wrote: > I don't think you understand. We do not want the template to be able to > execute any queries that have not already been done by the time it's > hit the render phase. If it hasnt been executed, we don't want it > accessible. The reason for this is to stop queries going outside of our > cache and/or view.
They're still happening "in the view", though -- the view doesn't return until *after* the template is rendered. If you use full-page caching, then those DB hits will be cached. Similarly, if you use the fine-grained caching to store the rendered template, those DB hits will be cached. You can even cache inside a template tag if you feel a need; *anywhere* that you're dealing in Python with a valid Python value (and a rendered template is just a Python string), you can stuff that value into the cache. There's nothing special about templates which exempts them from being cached. > Yes, this may limit templates, but it's a good limitation, there should > be no reason a template should have to pull information from the > database. Why? Because you can't cache the data within the template, it > is hit EVERY SINGLE TIME the page is loaded. No, you *can* cache data in the template. You can cache as much or as little of it as you like. > So let's say for example, > we have a page, that displays 100 search results, and for some reason > or another, we didn't have the user field selected in these results, > and the template is calling the user field. We now have a template > executing 100 select queries EVERY SINGLE VIEW. Or once every n seconds, where n is your cache timeout. -- "May the forces of evil become confused on the way to your house." -- George Carlin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---