1 2 3 4 5 6 7 8 | def clean(self):
try:
# do validation here
except ValidationError, e:
if blame_field:
self._errors[blame_field] = e.messages
else:
raise e
|
More like this
- Validation for 'unique' and 'unique_together' constraints (different version) by miracle2k 5 years, 10 months ago
- Automatically trim newforms text fields by miracle2k 5 years, 7 months ago
- Add ValidationError to a field instead of __all__ during Form.clean() by guettli 4 years, 7 months ago
- Scan uploaded file for viruses with clamav by uandt 4 years, 11 months ago
- use oldforms validators in newforms forms by garywilson 6 years, 1 month ago
Comments
This is how you can blame different fields for different errors:
#
oh.. I forgot to return the cleaned dictionary at the end. so there should be
after all.
#
Archatas, instead of: self._errors['field1'] = self._errors.get('field1', [])
you should do: self._errors['field1'] = self._errors.get('field1', ErrorList())
ErrorList comes from django.forms.utils
#