I am using the newforms functionality, but I am having trouble
validating my form when two fields are needed to create the validation
rule. In particular, I want to verify that two password fields have
the same value. I thought I could use the BaseForm.clean() method but
it is giving me the following error when I try to access a attribute
on self:

Exception Type:         AttributeError
Exception Value:        'CreateAccountForm' object has no attribute
'password_1'

I'm assuming this has something to do with field binding. Here's the
code snippit I wrote to do the validation:

class CreateAccountForm(forms.Form):
   name = forms.CharField(max_length=50)
   name_phonetic = forms.CharField(max_length=50)
   email = forms.EmailField()
   password_1 = forms.CharField(max_length=20)
   password_2 = forms.CharField(max_length=20)
   homepage = forms.URLField(verify_exists=True)

   def clean(self):
      if self.password_1 != self.password_2:
         raise form.ValidationError("passwords must be the same")
      return forms.Form.clean(self)

Any thoughts?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to