'Clean the form fields.
This is the place to perform checks that involve multiple form fields.'

def clean(self):

    cleaned_data = super(CourseModeForm, self).clean()
    mode_slug = cleaned_data.get('mode_slug')
    upgrade_deadline = cleaned_data.get('_expiration_datetime')
    verification_deadline = cleaned_data.get('verification_deadline')
    if ((upgrade_deadline is not None) and (mode_slug != CourseMode.VERIFIED)):
        raise forms.ValidationError('Only    the    "verified"    mode    can    have    an    upgrade    deadline.        For    other    modes,    please    set    the    enrollment    end    date    in    Studio.')
    if ((verification_deadline is not None) and (mode_slug not in CourseMode.VERIFIED_MODES)):
        raise forms.ValidationError('Verification    deadline    can    be    set    only    for    verified    modes.')
    if (verification_deadline is not None):
        if ((upgrade_deadline is not None) and (verification_deadline < upgrade_deadline)):
            raise forms.ValidationError('Verification    deadline    must    be    after    the    upgrade    deadline.')
    return cleaned_data
