Hello,

my form allows file uploads, and obviously I need to validate the received files. In order to validate the files, I need to read them.

Is there a way to access request.FILES from form.clean() method? I'd like to detect the invalid files within the form validation, so that I can render the errors should there be some.

I know I could write clean_field() methods, but still I need the access to the file to validate it. And also I have some javascript which adds additional <input> fields to the form so I don't really know exactly how many files I will need to validate, I need to validate all of them.

Currently my validation happens in in handle_uploaded_file() method, but when I raise a ValidationError from there, it doesn't come from the form.is_valid() and thus would result in HTTP 500 response in production.

Thanks.

--
Yours sincerely
  Daniel Gerzo


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to