Getting "This field is required" even though file is uploaded Getting "This field is required" even though file is uploaded django django

Getting "This field is required" even though file is uploaded


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.


Add enctype="multipart/form-data"

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