Fix validation.

This commit is contained in:
Ben Sturmfels 2021-12-07 17:49:57 +11:00
parent 3272a25a8d
commit c6b329f0cf
Signed by: bsturmfels
GPG key ID: 023C05E2C9C068F0

View file

@ -54,5 +54,5 @@ class AssignmentForm(forms.ModelForm):
]
def clean_period_ends(self):
if 'period_begins' in cleaned_data and 'period_ends' in cleaned_data and cleaned_data['period_begins'] > cleaned_data['period_ends']:
if 'period_begins' in self.cleaned_data and 'period_ends' in self.cleaned_data and self.cleaned_data['period_begins'] and self.cleaned_data['period_ends'] and self.cleaned_data['period_begins'] > self.cleaned_data['period_ends']:
raise ValidationError('End of period is before start')