How to generate calendar based on datetime viariable view in template like this?
<< Jan Mar >>
Sun Mon Tue Wed Thu Fri Sat
开发者_StackOverflow社区 1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
in tables/div whatever...
simple django event calendar
You might find the stdlib module calendar
helpful:
>>> calendar.monthcalendar(2011, 9)
[[ 0, 0, 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, 9, 10, 11],
[12, 13, 14, 15, 16, 17, 18],
[19, 20, 21, 22, 23, 24, 25],
[26, 27, 28, 29, 30, 0, 0]]
(with whitespace added to show structure)
精彩评论