views:

91

answers:

1

Anyway to make a field conditionally required based on whether or not another field in the same form has been filled out?

If field1 has no data, but field2 does
    form is valid.

If field1 has no data and field2 has no data
    form is invalid

Not looking for any javascript solutions. I feel as it should be solved with django forms, but not quite sure how best to go about it.

+2  A: 

Override .clean(self) method, check for self.cleaned_data and raise ValidationError

http://docs.djangoproject.com/en/1.1/ref/forms/validation/#form-field-default-cleaning

iElectric