I am learning django framework and trying to read an excel file
I want to upload file using html form(POST Method) and want to read in python for calculations so what should I do really confused ? Code Is Here form.html
<form method="POST" action="minmax_ans.html">{% csrf_tocken %}
{{form.as_p}}
<p><b><h2>Upload File</h2></b><p>
<input type="file" name="file" value="{{ source.title }}">
<input type="submit">
</form>
views.py
def upload_file(request):
if request.method == 'POST':
form = UploadFileForm(request.POST, request.FILES)
if form.is_valid():
handle_uploaded_file(request.FILES['file'])
return HttpResponseRedirect('/success/url/')
else:
form = UploadFileForm()
return render(request, 'upload.html', {'form': form})
I want to do some calculations using data in the file uploaded through html form if it is an excel file and display the result on result.html which I have not created yet because I cannot read the file