On 25 nov, 10:04, "David Zhou" <[EMAIL PROTECTED]> wrote: > On Tue, Nov 25, 2008 at 3:55 AM, sajal <[EMAIL PROTECTED]> wrote: > > Now Id like to show age of the people along with their names. > > > I have a function which can calculate age callable via calculateAge > > (p.date_of_birth) but how do I make pass this along with the person > > object? > > There's several ways you could approach this: > > 1. Create a new template tag (snip) > 2. Add a current_age method to the Person model, (snip) > > 3. Return a list of tuples in your context processor: > (snip)
You forgot one: write a custom filter: @register.filter def calculate_age(date): return some_calculation(date) {% load myfilters %} {% for person in borntoday %} {{ person }} - {{ person.date_of_birth|calculate_age }} {% endfor %} --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---