6๐
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.
29๐
Check that you have added enctype
property into form
tag.
Example from official docs:
<form enctype="multipart/form-data" method="post" action="/foo/">
- A good way to encrypt database fields?
- How to add attributes to option tags?
- Returning CSV format from django-rest-framework?
2๐
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 question
print 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.
- How to test login process?
- How to Hash Django user password in Django Rest Framework?
- Django Aggregate- Division with Zero Values
- Django, register user with first name and last name?
1๐
<input type="file" id="grade_csv" name="name" />
You have to add name to your input field.
1๐
Two things to make sure of here:
- Form tag should contain attribute "enctype="multipart/form-data"
- Each file field should have a "name" attribute
- Cross platform interface for virtualenv
- How to make sure Django models match the database schema
- Django check if checkbox is selected
0๐
I just encountered a weird bug where it shows as empty when I print it out:
print(request.FILES)
# Prints <MultiValueDict: {}>
If I load up a debugger and actually inspect the object though, itโs not empty and contains the data I was expecting. This is the same exact object in both cases. The debugger shows FILES
as populated, then when I continue, print
shows it as empty.
So, if youโre like me and you wanted to poke at the object first to understand it a bit, maybe donโt rely on MultiValueDict
โs string representation. I canโt explain the source of the bug though since MultiValueDict
is just subclass of dict
and uses dict
โs __str__
.
- How to choose the value and label from Django ModelChoiceField queryset
- Issues with queryset and slicing
- Django how to set request user in client test
- DataTables: Custom Response Handling
- Django ChoiceField populated from database values