You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, i am new here. So be kind to me if I wrote stupidity)
But it's look like you forgot to return clean_data from method clean() in pics/forms.py/CreateForm
according to documentation:
The clean() method on a Field subclass is responsible for running to_python(), validate(), and run_validators() in the correct order and propagating their errors. If, at any time, any of the methods raise ValidationError, the validation stops and that error is raised. This method returns the clean data, which is then inserted into the cleaned_data dictionary of the form.
` Now it's:
def clean(self):
cleaned_data = super().clean()
pic = cleaned_data.get('picture')
if pic is None:
return
if len(pic) > self.max_upload_limit:
self.add_error('picture', "File must be < "+self.max_upload_limit_text+" bytes")`
Also we can see that super().clean() return clean_data
` May be it should be like this:
def clean(self):
cleaned_data = super().clean()
pic = cleaned_data.get('picture')
if pic is None:
return clean_data
if len(pic) > self.max_upload_limit:
self.add_error('picture', "File must be < "+self.max_upload_limit_text+" bytes")
return clean_data`
p.s. may be it should also raise ValidationError after self.add_error(....)? Otherwise how is_valid() will know about error. Or it will take information from self.add_error(....)?
The text was updated successfully, but these errors were encountered:
Hi, i am new here. So be kind to me if I wrote stupidity)
But it's look like you forgot to return clean_data from method clean() in pics/forms.py/CreateForm
according to documentation:
` Now it's:
Also we can see that super().clean() return clean_data
` May be it should be like this:
p.s. may be it should also raise ValidationError after self.add_error(....)? Otherwise how is_valid() will know about error. Or it will take information from self.add_error(....)?
The text was updated successfully, but these errors were encountered: