from datetime import datetime from icalendar import Calendar, Event from django.db.models import get_model from django.http import HttpResponse from django.contrib.sites.models import Site def export(request, event_id): event = get_model('events', 'event').objects.get(id = event_id) cal = Calendar() site = Site.objects.get_current() cal.add('prodid', '-//%s Events Calendar//%s//' % (site.name, site.domain)) cal.add('version', '2.0') site_token = site.domain.split('.') site_token.reverse() site_token = '.'.join(site_token) ical_event = Event() ical_event.add('summary', event.description) ical_event.add('dtstart', event.start) ical_event.add('dtend', event.end and event.end or event.start) ical_event.add('dtstamp', event.end and event.end or event.start) ical_event['uid'] = '%d.event.events.%s' % (event.id, site_token) cal.add_component(ical_event) response = HttpResponse(cal.as_string(), mimetype="text/calendar") response['Content-Disposition'] = 'attachment; filename=%s.ics' % event.slug return response Add to URLS.py: urlpatterns += patterns('', url(r'^events/(?P<event_id>\d+)/export/', 'app_events.ics_views.export', name="event_ics_export"), ) And invoke via: Export Event