python内置htmlcalendar的django-fied模板版本。
django-tempocal的Python项目详细描述
python stdlib的calendar.HTMLCalendar的一个扩展,它使用django模板定制输出。毕竟,有硬编码的html输出是很糟糕的。
用法:
pip install django-tempocal
将'tempocal'添加到INSTALLED_APPS中。
fromtempocalimportTemplatedCalendardefmyview(request,year,month):calendar=TemplatedCalendar()month_table=calendar.formatmonth(int(year),int(month))returnrender_to_response('myview.html',{'month_table':month_table})
这将使用tempocal附带的tempocal/month.html,您可以通过普通的django机制覆盖它。