-
-
Notifications
You must be signed in to change notification settings - Fork 17
This field is required error #214
-
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?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments
-
Hi there,
Thanks for reaching out. You shouldn't need to use multipart/form-data
, since you don't send the file via the form. However, I am curious, are you running this on S3 or local development?
I would recommend opening up the browser console and to look out for any errors. That information would be useful for me to help you with your problem.
Best,
Joe
Beta Was this translation helpful? Give feedback.
All reactions
-
I tried it with a fresh project that doesn't have any other middlewares and found out that the error was on my part, sorry. Probably should've tried to do that prior to opening an issue. Fixed the problem in my code and now it works. I have a different problem related to the progress bars, though. I'll create a new discussion for that. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1