I need to add event calendar functionality to my application, and I'm wondering what do you think is the best way to do it ? Are there any interesting projects providing the needed functionality ? A snippet : http://djangosnippets.开发者_Python百科org/snippets/129/ ? Write it on my own ?
Without knowing the level of complexity you need, I always suggest quick and easy first. Once minimum requirements are established you can confidently migrate.
Django Flatpages can take you a long way with very little effort.
If you're looking to go all the way, setting up a DAViCal server with some kind of python bindings would give you a very flexible application. The integration with Django looks like it would have to be built from scratch, but all the heavy lifting is done in DAViCal and the python bindings.
DAViCal would allow you to access the calendar from several different applications, making your solution much more robust.
If you're willing to build your own, I found Python's Calendar module to be great. I used calendar.monthcalendar() to build a table-layout calendar. The module has many useful functions in it and recommend checking it out if you haven't already.
Here's more info on calendar.monthcalendar(year, month):
Returns a matrix representing a month’s calendar. Each row represents a week; days outside of the month a represented by zeros. Each week begins with Monday unless set by setfirstweekday().
If you want your calendar to start on Sunday as opposed to the Monday default, just:
calendar.setfirstweekday(6)
精彩评论