I am trying to figure out how to read a downloaded CSV without saving it to disk ...
I am stuck in form.cleaned_data ['file']. read ... I seem to be getting nothing
If I can only figure out how to get the output, then I can write the appropriate function to process the data rows.
#addreport.html <form enctype="multipart/form-data" method="post" action="/products/addreport/"> {%csrf_token %} <table> {{ form.as_table }} </table> <input type="submit" value="Submit" />
#forms.py from django import forms
-
# views.py def addreport(request): if request and request.method == "POST": form = UploadFileForm(request.POST, request.FILES) if form.is_valid(): print form.cleaned_data['file'].read() else: print form.errors print request.FILES
source share