Django: Anulando el método clean () en formularios - pregunta sobre cómo generar errores
He estado haciendo cosas como esta en el método limpio:
if self.cleaned_data['type'].organized_by != self.cleaned_data['organized_by']:
raise forms.ValidationError('The type and organization do not match.')
if self.cleaned_data['start'] > self.cleaned_data['end']:
raise forms.ValidationError('The start date cannot be later than the end date.')
Pero eso significa que el formulario solo puede generar uno de estos errores a la vez. ¿Hay alguna forma para que la forma genere ambos errores?
EDITAR # 1: Cualquier solución para lo anterior es excelente, pero amaría algo que también funcionaría en un escenario como:
if self.cleaned_data['type'].organized_by != self.cleaned_data['organized_by']:
raise forms.ValidationError('The type and organization do not match.')
if self.cleaned_data['start'] > self.cleaned_data['end']:
raise forms.ValidationError('The start date cannot be later than the end date.')
super(FooAddForm, self).clean()
Donde FooAddForm es un ModelForm y tiene restricciones únicas que también pueden causar errores. Si alguien sabe algo como eso, sería genial ...