I dont think that helps, but I have just realised when fiddling around that if both template tags really were being called it would have raised an error as only one isn't always valid.
The debugging output I was seeing came from the __init__ of my template tag's Node class. However, the render method isn't called, and thus the database isn't actually touched. So really it's not an issue, but possibly something to be aware of. Pete On Oct 16, 5:11 pm, dononyx <don.guern...@gmail.com> wrote: > try firstof?? > {% firstof var1 var2 var3 %} > This is equivalent to: > > {% if var1 %} > {{ var1 }} > {% else %}{% if var2 %} > {{ var2 }} > {% else %}{% if var3 %} > {{ var3 }} > {% endif %}{% endif %}{% endif %} > > On Oct 16, 9:49 am, "pjrhar...@gmail.com" <pjrhar...@gmail.com> wrote: > > > I have some template code which looks something like this: > > {% if condition %} > > {% get_latest parameter1 %} - foo > > {% else %} > > {% get_latest parameter2 %} - bar > > {% endif %} > > > get_latest is a custom template tag, and I noticed that in my > > debugging output it is being run both times - ie with parameter1 and > > parameter2. Since it hits the database I'd rather not have it do > > this. > > > On the other hand only foo or bar appears in the rendered page. I > > guess the template system renders all the tags, then discards > > whichever branch does not apply. > > > So the question is, can I avoid this? Or should I just change my > > template tag so I can call it with: > > {% get_latest condition parameter1 parameter2 %} > > > Thanks, > > > Pete --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---