I am going to have a web app that does some processing on user data and is going to give him/her back an excel file of processed data in Django.
here is my app/views.py
function:
@login_required(login_url='/signin/')
def processing(request):
...
# read imported file (uploaded by user) and do the process.
# finally have 3 uf, vf, wf array.
...
# save the file in "excel_file = models.FileField"
from pandas import DataFrame, ExcelWriter
data = {
'uf': uf,
'vf': vf,
'wf': wf,
}
excel_data = DataFrame(excel_data)
despiked = Despiking(
#other models
excel_file=excel_data.to_excel(???),
)
despiked.save()
return render(request, 'filteration/despiking.html', context=context)
how can I save the excel_data
into its model (excel_file
) and create its media into Media
directory?
I already have read django pandas dataframe download as excel file question, but wasn't able to fix the problem with HttpResponse
. any help would be greatly appreciated