Hi, On Wed, Oct 15, 2008 at 01:46:38PM -0700, bmt wrote: > my problem is that when this list is empty i want to branch in the > template, and display some sort of message, instead of the usual 'for' > loop which would display the returned list. since i can't assign the > returned list to a variable i have to check the method's return value > first with an 'if' tag than run the query again for the 'for' loop. > this doubles the load on the db what i don't like, not to mention that > the two queries may return different lists. > > am i missing something? do i follow a bad pattern? why i can't extend > the context from inside a template?
Does the {% with %} tag help you here? Something like: {% with blah.get_some_results as foo %} {% if foo %} ... {% else %} ... {% endif %} {% endwith %} Otherwise, since it's your object, you could always cache the result of the query in the object. Cheers, Chris --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---