Instead of adding a template tag, you could handle this in the class for obj. Just have get_votes() cache its result and use the cached value after the first time get_votes() is called. In the template, always call get_votes().
Brett On 11/7/11 4:12 PM, "Nikolas Stevenson-Molnar" <nik.mol...@consbio.org> wrote: >Ah, ok; I see what you want to do. I'm not aware of any way to do this, >other than as you mentioned a custom template tag. > >On 11/7/2011 2:04 PM, bax...@gretschpages.com wrote: >> >> On Nov 7, 3:50 pm, Nikolas Stevenson-Molnar <nik.mol...@consbio.org> >> wrote: >>> Assuming obj is iterable, you can do: {% with >>> obj.0.thingobj.get_something as thing %} >>> >>> ...is that what you mean? >> Not exactly, no. In my particular case, it's more of a check to see if >> it's available, and if not, do a bit more work to get something that >> will fill the current need. Or, in other words, maybe I'm storing it >> locally, or maybe I'm not. >> >> Another example: >> >> {% with firstof obj.votes obj.get_votes as votes %} >> Which would then let me do something with votes: "There have been >> {{ votes }} vote{{ votes|pluralize }}. >> > >-- >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. > -- 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.