yuliji
5/5/2017 - 9:15 AM

django return binary

django return binary

@detail_route(methods=['get'])
def fetch_report(self, request, *args, **kwargs):
    short_report = open("somePdfFile", 'rb')
    response = HttpResponse(FileWrapper(short_report), content_type='application/pdf')
    response['Content-Disposition'] = 'inline; filename="myfile.csv"'
    return response