我想在日历的第一天定为星期日,但我不确定该怎么做。我知道calendar.setfirstweekday()是可用于日历的方法,但我不知道HTMLCalendar可以使用它。
utils.py
class Calendar(HTMLCalendar):
def __init__(self, year=None, month=None, user=None):
self.year = year
self.month = month
self.user = user
super(Calendar, self).__init__()
Views.py
class CalendarView(generic.ListView):
model = Event
template_name = 'accounts/calendar.html'
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
user = self.request.user
cal = Calendar(d.year, d.month, user)
html_cal = cal.formatmonth(withyear=True)
context['calendar'] = mark_safe(html_cal)
return context