request.FILES always empty on file upload request.FILES always empty on file upload django django

request.FILES always empty on file upload


Check that you have added enctype property into form tag.

Example from official docs:<form enctype="multipart/form-data" method="post" action="/foo/">


I hope that you have already solved this issue.I had the exactly same issue and I found out I had no name prop in input tag

<input type="file" id="grade_csv" /> that is your input.

if it doesn't have name, django won't take it.So add name prop then it will work well.


I had this problem too and was puzzling over it for a while. My error was the same -- that I was missing necessary fields on the input field.

In order to see what the actually required fields are, a very nice thing to do is, in this case:

from base.forms import DocumentForm ## or put whatever the name is of the app, which is unspecified in the questionprint DocumentForm()

This will print the html that you need, including all the tags that this object requires. Very neat functionality which I missed the first time, but which is outlined in the docs.