Hi all i am both a Django and python noob.

The thing is I have a database of people and need to show a widget on
all pages listing out people who are celebrating their birthday today.

Using them in each views didnt seem right, specially since later id
like this portion of the page to be cached so it doesnt seem right.

I added a custom context processor with the function :-

def borntoday(request):
    date = datetime.date.today()
    return {'borntoday': Person.objects.filter
(date_of_birth__month=date.month, date_of_birth__day=date.day)}

In my template i access this as :-

{% if borntoday %}
<div class="borntoday">
    <h4>Birthday file - {{ date|date:"jS F" }}</h4>
    <ol>
    {% for person in borntoday %}
        <li><a href="{{ person.get_absolute_url }}">{{ person }}</a></li>
    {% endfor %}
    </ol>
</div>
{% endif %}



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?

I am too new in python, do i need to re-assemble the python list?

Could someone point me to some sample code which can add the age into
the list being passed to the template?

BTW is my approach the correct one or am I supposed to tackale this
problem in a diferent manner?

Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to