Is there a way to set the accepted file types in a django forms.FileInput() widget? I want it to accept only .txt and .pdf.
The docs, contain nothing. If this is not at all possible, how can we add the validation at client side for a django form?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You should ideally do this when cleaning your form data and return an error if its not the extension type you want.
But there is a django snippet that shows an example of how to do this using a custom form field: http://djangosnippets.org/snippets/977/