[Fixed]-Getting "This field is required" even though file is uploaded

55👍

As you haven’t posted your view, I can only guess its because you forgot to include request.FILES:

form = ProfileForm(request.POST, request.FILES)

And perhaps forgot to add enctype=multipart/form-data to your form.

6👍

Add enctype="multipart/form-data"

<form enctype="multipart/form-data" method="post">
    {% csrf_token %}
    {{ form.as_p }}
<button type="submit">Upload</button>
</form>

Leave a comment