제기에 대해 질문 :장고 : 형태의 깨끗한() 메소드를 오버라이드 (override) - 오류
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.')
하지만 형태는 중 하나를 올릴 수 있다는 의미를 한 번에 이러한 오류. 양식에서 이러한 오류를 모두 제기 할 수있는 방법이 있습니까?
편집 # 1 : 위 대한 모든 솔루션은 중대하다,하지만 같은 시나리오에서 일하는 것이 뭔가를 사랑 : FooAddForm이 ModelForm이며 그 수도 고유 제한 조건을 가지고
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()
또한 오류를 유발합니다. 사람이 그런 뭔가 알고 있다면, 그 워드 프로세서
매우 잘 작동합니다. 오류 메시지가 전체 양식이 아닌 필드에 첨부 된 것이 마음에 들지는 않지만 실제로는 이 방식으로 더 의미가 있습니다) 및 ModelForm 고유 제약 조건도 작동합니다. 그래서 나는 이것을 받아들입니다 - 감사합니다! :) –