I want to write a dynamic file that generated me a report in txt format, for this I created a function that returns the file and downloads it, but it is returning empty. Here part of the code:
file_content = "Este es el contenido de los reportes"
file_name = "Report " + str(date.today()) + ".txt"
file = open(file_name,'w')
file.write(file_content")
file.close()
response = HttpResponse(content_type='application/force-download')
response['Content-Disposition'] = 'attachment; filename={}'.format(file_name)
response['X-Sendfile'] = file
return response
At the end of this function if the file is returned to me, but it is empty .... jelpmi