title: Django Calendar View - How to Pass the URL
body: <p>I need a calendar to display entries on a timesheet. I was using <a href="http://uggedal.com/journal/creating-a-flexible-monthly-calendar-in-django/" rel="nofollow">this guide</a> to writing a django calendar, but it does not cover the final stage, that is to say, actually passing the url to a view and rendering the calendar. Based on an educated guess gone wrong, my urlconf entry has now become this monstrosity:</p>
  
  <pre><code>        url(r'^calendar/(?P&lt;pk&gt;\d+)/(?P&lt;start__year&gt;\d+)/(?P&lt;start__month&gt;\d+)/$', calendar(request, year, month)),
  </code></pre>
  
  <p>The view itself is thus:</p>
  
  <pre><code>def calendar(request, year, month):
      my_timesheet = Timesheet.objects.order_by('start').filter(start__year=year, start__month=month)
      cal = TimesheetCalendar(my_timesheet).formatmonth(year, month)
      return render_to_response('calendar.html', {'calendar':mark_safe(cal),})
  </code></pre>
  
  <p>and the calender generation is:</p>
  
  <pre><code>class TimesheetCalendar(HTMLCalendar):
      def __init__(self, Timesheet):
          super(TimesheetCalendar, self).__init__()
          self.Timesheet = self.group_by_day(Timesheet)
  
      def formatday(self, day, weekday):
          if day != 0:
              cssclass = self.cssclasses[weekday]
              if date.today() == date(self.year, self.month, day):
                  cssclass += ' today'
              if day in self.Timesheet:
                  cssclass += ' filled'
                  body = ['&lt;ul&gt;']
                  for timesheet in self.Timesheet[day]:
                      body.append('&lt;li&gt;')
                      body.append(esc(Timesheet.activity))
                      body.append('&lt;/li&gt;')
                  body.append('&lt;/ul&gt;')
                  return self.day_cell(cssclass, '%d %s' % (day, ''.join(body)))
              return self.day_cell(cssclass,day)
          return self.daycell('noday','&amp;nbsp;')
  
      def formatmonth(self, year, month):
          self.year, self.month = year, month
          return super(TimesheetCalendar, self).formatmonth(year, month)
  
      def group_by_day(self, Timesheet):
          field = lambda Timesheet: Timesheet.start.day
          return dict(
              [(day, list(items)) for day, items in groupby(Timesheet, field)]
              )
      def day_cell(self, cssclass, body):
          return '&lt;td class="%s"&gt;%s&lt;/td&gt;' %(cssclass, body)
  </code></pre>
  
  <p>What must I do to correctly pass those attributes, month and year, from the datefield <code>start</code> in my model?</p>