This field is required error
Closed this issue · 0 comments
isik-kaplan commented
With this simple setup:
direct_s3_storage = S3OptimizedUploadStorage()
class FileUpload(models.Model):
file = models.FileField(storage=direct_s3_storage)
class CsvUploadForm(ModelForm):
class Meta:
model = FileUpload
fields = ["file"]
class FileUploadView(FormView):
form_class = FileUploadForm
template_name = "upload.html"
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form }}
</form>
{{ form.media.js }}
I keep getting File: This field is required.
When I add {{ form.media.js }} request.FILES is empty, and "file" in request.POST, when I remove the {{ form.media.js }} request.FILES has "file" and "file" not in request.POST
I have the app and the middleware.
I've tried to figure it out myself but couldn't. I feel like I'm missing something, but I'm not entire sure what. Should I initiate my form differently?