I am having trouble getting access to a simple uploaded file which I need to parse without saving it. Since the file does not need to be saved I have not made a model for it. All other threads on this state the html form encoding type, name tag are the primary reasons why request.FILES is not appearing-- I have addressed these and still there is no request.FILES being captured.
forms.py
class DataExportForm(forms.Form):
docfile = forms.FileField(label='Select a template',help_text='Extracted info will be returned')
HTML
<html>
<body>
<form action="." method="post" enctype="multipart/form-data">{% csrf_token %}
<tr><th><label for="id_docfile">Select a template:</label></th><td><input id="id
_docfile" name="docfile" type="file" />
<button type="submit" name="action">Upload</button>
<br /><span class="helptext">Zip file wil
l be returned with data</span></td></tr>
</form>
</body>
</html>
views.py
if request.method=='POST':
form=DataExportForm(request.POST, request.FILES)
if form.is_valid():
#Code runs OK till here but request.FILES does not exist.
groupList=extractTemplateNames(request.FILES['file'].read())
I guess if I get it working I may find the file not in request.FILES['file'] but in request.FILES['docfile'] but at this point request.FILES does not exist. Any tips to solve this would be appreciated.