Skip to content

Instantly share code, notes, and snippets.

@makotoworld
Created January 26, 2012 08:32
Show Gist options
  • Save makotoworld/1681764 to your computer and use it in GitHub Desktop.
Save makotoworld/1681764 to your computer and use it in GitHub Desktop.
Django でiCalカレンダーを生成する
https://github.com/statesofpop/django-cal
import vobject.iCalender
def ical(user_id=None):
cal = vobject.iCalendar()
cal.add('method').value = 'PUBLISH'
cal.add('calscale').value = 'GREGORIAN'
cal.add('x-wr-calname').value = 'TestCal28'
cal.add('x-wr-timezone').value = 'Australia/Sydney'
cal.add('x-wr-caldesc').value = ''
vevent = cal.add('vevent')
vevent.add('dtstart').value = datetime.now()
vevent.add('dtend').value = datetime(2010, 7, 22)
vevent.add('dtstamp').value = datetime.now()
vevent.add('summary').value = "Test event"
icalstream = cal.serialize()
print cal.serialize()
response = HttpResponse(icalstream, mimetype='text/calendar')
response['Filename'] = 'filename.ics'
response['Content-Disposition'] = 'attachment; filename=filename.ics'
ical()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment