This is how I solved it!

my model is like this:

class userForm(forms.Form):
        username = forms.CharField()
        display_name = forms.CharField()
        email_address = forms.EmailField()
        timezone = TimeZoneField()
        password1 = forms.CharField(widget=forms.PasswordInput)
        password2 = forms.CharField(widget=forms.PasswordInput)
        email_notification = forms.ChoiceField(widget = forms.RadioSelect,
choices = ((True, "Yes"),(False, "No")))
        administrator = forms.ChoiceField(widget = forms.RadioSelect, choices
= ((True, "Yes"),(False, "No")))
        auto_assign = forms.ChoiceField(widget = forms.RadioSelect, choices =
((True, "Yes"),(False, "No")))

        def clean_username(self):
                n = self.cleaned_data['username']
                try:
                        User.objects.get(username=n)
                except User.DoesNotExist:
                        return n
                raise ValidationError('The username "%s" is already taken.' % n)
        def clean_password1(self):
                password1 = self.cleaned_data["password1"]
                password2 = self.cleaned_data["password2"]
                if password1 != password2:
                        raise ValidationError('Passwords must match.')
                else:
                        return password2


I was getting an Keyerror password2 My mistake was I should define
clean_password2(self) rather than clean_password1(self):
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to