Pete,
I'm not completely familiar with you problem or what exactly
'get_latest' does.
But my intuition is that you may wish to consider rewriting
'get_latest' to be more "lazy"
If it is not exactly clear what I mean by that see Django online docs
on lazy querysets
e.g. http://docs.djangoproject.com/en/dev/topics/db/queries/#querysets-are-lazy

I became a big fan of laziness when I learned Haskell last year.
IMHO laziness is usually a good design consideration.

Of course this advice might not really apply to your problem - it's
just a suggestion

-Chip

On Oct 16, 8: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
-~----------~----~----~----~------~----~------~--~---

Reply via email to