I'm hoping to get a sanity check for how I'm using the clean method. I'm using new forms and I wanted to do a sanity covering the relationship of two different fields. The form as auto created with form_for_instance and friends was just fine, I just needed a "clean()" method of my choosing. I got something working (after trying several very hacky things) and here is the least hacky thing I ended up with. Still seems a little weird to me for some reason. I'd just like some advice on whether this is how it's designed to work or if I'm still missing something.
class LabOrderForm(forms.BaseForm): def __init__(self, *s, **kw): forms.BaseForm.__init__(self, *s, **kw) def clean(self): index_number = self.cleaned_data.get('index_number') nih_contract_code = self.cleaned_data.get('nih_contract_code') if index_number: if (index_number.contract_type == 'nih' and not nih_contract_code or index_number.contract_type != 'nih' and nih_contract_code): raise forms.ValidationError('all nih contracts (and only nih contracts) must have an associated contract number') return forms.BaseForm.clean(self) This can then be instantiated with: forms.models.form_for_instance(original_laborder, form=LabOrderForm) Is there a more django-esque to get a custom clean method for an auto- generated form like this or is this the way it's supposed to go? Also it seems that newforms doesn't respect the validator_list in the model, is that correct? As designed? thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---