I get the idea. My trouble is caused by going through a method then dict keys. Your example is the easiest for me I guess (without overhead development of template tags which I never played with... yet). I am thinking of an alternate way, where some 'init' method would stick the dict values as attributes to my object. Then I can access these attributes from the template painlessly.
My confusion came from the assumption that, when a template is computed, the variables/attributes/returned_results/keys it needs are treated only once. I believed that no data were to be altered while rendering the template, which makes more sense to me as I'd prefer to decouple business logic from template rendering. Anyway, thanks for your reply. Jeremy Dunck a écrit : >On 7/25/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > >>If so, I may have performance issues if the processing in the method >>takes some time :-( >> >> > >The method will be called each time-- django can't know whether the >method is deterministic. Suppose you wanted a method to return the >current time? > >It the dict will be the same each time it's called, you have a few >options: make a template tag and cache the result in the node, or >store the result locally and just return the stored result if >available. > >So: > >class model(...): > def __init__(self, ...): > self._previous_dict = None > def expensive_dict(self, ...): > if self._previous_dict: > return self._previous_dict > > #..expensive stuff here > self._previous_dict = results_of_process > >> > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---