django-rest-framework-csv
django-rest-framework-csv copied to clipboard
response['Content-Type'] not set
Is it an issue with my code or a bug of django-rest-framework-csv?
class DataList(generics.ListAPIView):
...
renderer_classes = [CSVRendererWithUnderscores, ]
...
def finalize_response(self, request, response, *args, **kwargs):
response = super(DataList, self)\
.finalize_response(request, response, *args, **kwargs)
response['Content-Disposition'] = \
"attachment; filename=data_{:s}.csv"\
.format(kwargs['year'])
return response
Adding response['content-type'] = 'text/csv' wouldn't help.
I agree that exist problem with this and easy set filename to download or add right ['Content-disposition']
I guesing that here was try to set both ['Content-disposition'] and ['content-type']
With this hard is to realize plain/text as txt/csv to show in browser and download as view to set extension as .txt or .csv (instead of autodownload - it's important in case API should provide some tables to usage instaed of json/xml).