I am defining a Form class which has a filefield and is not mandatory to add a file to it…but whenever i do not provide a file the form is invalid….so is there any way by which i can make it optional for user to add a file or not???
Share
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.
Yes, it is definitely possible, so check if you have required=False.
Quoting from documentation for django 1.4: “By default, each Field class assumes the value is required, so if you pass an empty value — either None or the empty string (“”) — then clean() will raise a ValidationError exception:” ( https://docs.djangoproject.com/en/1.4/ref/forms/fields/#required )