Alguien puede ayudarme con este error en Django con python 2.7. Estoy tratando con este codigo implementar un calendario.
Estoy teniendo un error en la variable context['calendar'] = mark_safe(html_cal)
Nose que estoy haciendo mal.
from datetime import datetime
from django.shortcuts import render
from django.http import HttpResponse
from django.views import generic
from django.utils.safestring import mark_safe
from .models import *
from .utils import Calendar
class CalendarView(generic.ListView):
model = Event
template_name = 'agendas/templates/calendar.html'
def get_context_data(self, **kwargs):
context = super(CalendarView,self)
# use today's date for the calendar
d = get_date(self.request.GET.get('day', None))
# Instantiate our calendar class with today's year and date
cal = Calendar(d.year, d.month)
# Call the formatmonth method, which returns our calendar as a table
html_cal = cal.formatmonth(withyear=True)
context['calendar'] = mark_safe(html_cal)
return context
def get_date(req_day):
if req_day:
year, month = (int(x) for x in req_day.split('-'))
return date(year, month, day=1)
return datetime.datetime.today()
El error en el log de Django
'super' object does not support item assignment
context['calendar'] = mark_safe(html_cal)
Aqui esta descrito la variable context.
<super: <class 'CalendarView'>, <CalendarView object>>
d datetime.datetime(2020, 3, 25, 23, 26, 52, 368050)
self <comutechapps.agendas.views.CalendarView object at 0x7fbb7d6d0250>
cal <comutechapps.agendas.utils.Calendar object at 0x7fbb79e94a90>
html_cal '<table border="0" cellpadding="0" cellspacing="0" class="calendar">\n{self.formatmonthname(self.year, self.month, withyear=withyear)}\n{self.formatweekheader()}\n{self.formatweek(week, events)}\n{self.formatweek(week, events)}\n{self.formatweek(week, events)}\n{self.formatweek(week, events)}\n{self.formatweek(week, events)}\n{self.formatweek(week, events)}\n'
kwargs {}