I am a new to django and python. Need some guidance in this quest.
Case: When the user hits the submit button on a form, it should display Success page and a link wh
Now it works but i had to change file extension from excel (.xls) to csv.
My urls.py=url(r'^static/example.txt', send_file)
My HTML link=Download CSV File
My view.py
def send_file(request):
import os, tempfile, zipfile
from wsgiref.util import FileWrapper
from django.conf import settings
import mimetypes
filename = "C:\ex2.csv" # Select your file here.
download_name ="example.csv"
wrapper = FileWrapper(open(filename))
content_type = mimetypes.guess_type(filename)[0]
response = HttpResponse(wrapper,content_type=content_type)
response['Content-Length'] = os.path.getsize(filename)
response['Content-Disposition'] = "attachment; filename=%s"%download_name
return response