Hello, I am currently using the Calendar Templatetag found at http://djangosnippets.org/snippets/129/ and it suites my current needs. However, I would like to extend the functionality of the templatetag by rendering previous and next months i.e., June 2010, July 2010, August 2010, September 2010 as well as capturing events in multiple days. I looked at Django-Schedule and Swingtime, but the apps are too complex for my simple needs.
The code: from datetime import date, timedelta from django import template from myapp.models import Event register = template.Library() from datetime import date, timedelta def get_last_day_of_month(year, month): if (month == 12): year += 1 month = 1 else: month += 1 return date(year, month, 1) - timedelta(1) def month_cal(year, month): event_list = Event.objects.filter(start_date__year=year, start_date__month=month) first_day_of_month = date(year, month, 1) last_day_of_month = get_last_day_of_month(year, month) first_day_of_calendar = first_day_of_month - timedelta(first_day_of_month.weekday()) last_day_of_calendar = last_day_of_month + timedelta(7 - last_day_of_month.weekday()) What is the best method for adding this added functionality. Am I better writing views or context processor month_cal = [] week = [] week_headers = [] i = 0 day = first_day_of_calendar while day <= last_day_of_calendar:What is the best method for adding this added functionality. Am I better writing views or context processor if i < 7:What is the week_headers.append(day) cal_day = {} cal_day['day'] = day cal_day['event'] = False for event in event_list: if day >= event.start_date.date() and day <= event.end_date.date(): cal_day['event'] = True if day.month == month: cal_day['in_month'] = True else:s are cal_day['in_month'] = False week.append(cal_day) if day.weekday() == 6: month_cal.append(week) week = [] i += 1 day += timedelta(1) return {'calendar': month_cal, 'headers': week_headers} register.inclusion_tag('agenda/month_cal.html')(month_cal) My question is: How should I attempt to add this functionality given the model that I am currently using uses a start_date and end_date. Appreciate yours inputs and suggestions. VR, _Mario -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.