I want to plot my milestones into a 28-week calendar using Django. What would be the best approach to doing that?
I have the following code: [dashboardcalendar.py (custom template tag)] from datetime import datetime, timedelta from django.template import Library,Node register = Library() def plot_calendar(context): """ Plot milestones into an XHTML calendar Calendar starts today and ends at the end of day range defined by days (default = 28) """ week = [datetime.today() + timedelta(days = n) for n in range(7)] week_days = [d.strftime("%A") for d in week] # calendar_milestones is a list of Milestone model objects # with date_close (date) attribute if context.has_key('calendar_milestones'): milestones = context['calendar_milestones'] else: milestones = None if not context.has_key('weeks'): days = int(context['weeks']) * 7 else: days = 28 dates = [] for n in range(days): date = datetime.today() + timedelta(days=n) dates.append(date) return { 'week_days': week_days, 'calendar_days': dates, 'calendar_milestones': milestones, } register.inclusion_tag('dashboard/widgets/calendar.html', takes_context = True)(plot_calendar) and my template: [dashboard/widget/calendar.html (customfilters: isSunday, isFirstofMonth, isOverdue)] {% load customfilters %} {% if week_days %} <!-- BEGIN upcoming milestones claendar --> <table summary="Milestones due in the next 4 weeks" cellspacing='1' class="calendar"> <caption>Milestones due in the next 4 weeks</caption> <thead> <tr> {% for w in week_days %} <th>{{ w }}</th> {% endfor %} </tr> </thead> <tbody> {% if calendar_days %} {% for d in calendar_days %} {% if forloop.counter0|divisibleby:7 %} {% if not forloop.first %}</tr>{% endif %} {% if not forloop.last %}<tr>{% endif %} {% endif %} {% if forloop.first %} <td class="today"> <ul><li><strong>TODAY</strong> <!-- if there are milestones due today, list them here --> {% else %} {% if d|isSunday %}<td class="sunday">{% else %}<td>{% endif %} <ul><li>{% if d|isFirstOfMonth %}<strong class="black">{{ d|date:"j N" }}</strong>{% else %}{{ d|date:"j" }}{% endif %} <!-- if there are milestones due on that date, list them here --> {% endif %} </li></ul> </td> {% endfor %} {% else %} <tr> <td colspan="7"> <div class="error">Can't create calendar cells because I don't know the day range</div> </td> </tr> {% endif %} </tbody> </table> <!-- END upcoming milestones calendar --> {% endif %} <!-- just testing --> {% if calendar_milestones %} <ul> {% for m in calendar_milestones %} {% if m.date_close|isOverdue %}<li class="red">{% else %}<li>{% endif %} {{ m.date_close|date:"j F" }} | {{ m.name }} ({{ m.project.name }})</li> {% endfor %} </ul> {% endif %} --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---