diff --git a/src/agenda_culturel/views.py b/src/agenda_culturel/views.py index 630dce1..fb56d95 100644 --- a/src/agenda_culturel/views.py +++ b/src/agenda_culturel/views.py @@ -10,7 +10,7 @@ from django.http import QueryDict from django import forms from django.contrib.postgres.search import SearchQuery, SearchHeadline -from django.http import HttpResponseRedirect, FileResponse +from django.http import HttpResponseRedirect, HttpResponse from django.urls import reverse from collections import Counter @@ -606,13 +606,14 @@ def export_event_ical(request, pk): cal = Event.export_to_ics(events) - return FileResponse( - cal.to_ical().decode("utf-8").replace("\r\n", "\n"), - as_attachment=True, - filename=event.title + ".ics", - content_type="text/calendar", + response = HttpResponse(content_type="text/calendar") + response.content = cal.to_ical().decode("utf-8").replace("\r\n", "\n") + response["Content-Disposition"] = "attachment; filename={0}{1}".format( + event.title, ".ics" ) + return response + class EventFilterAdmin(django_filters.FilterSet): status = django_filters.MultipleChoiceFilter(