I have this working with some extra code in my view, but I would like to know 
how I could have done it in the template:

# view.py
from datetime import datetime, date


     # Week starts on Sunday
     c=calendar.Calendar(calendar.SUNDAY)

     # get all the dates that will be displayed,
     # including the tail and head of previous/next months.
     # (a list of weeks, each week is a list of 7 dates.)
     dates=c.monthdatescalendar(year, month)

     # array, ['Monday', 'Tuesday'.. 0 is Mon.
     daynamesarray=calendar.day_name
     # I can't figure out how to use the array in the template.
     # so I am building a list here.
     # Use the first week of the calandar, which is handy
     # because it makes sure the week starts on the weekday we want it to
     # (like Sunday)
     daynames= [ calendar.day_name[d.weekday()] for d in dates[0] ]


{% for dayname in daynames %}
<th>{{ dayname }}</th>
{% endfor %}

So what would the template code look like that uses daynamesarray and dates?

Carl K

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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