Dear all, I'm trying to make register page, but it it cannot compare 2 password, even if I submit different password it still run and didn't raise ValidationError, please help me. My forms.py as per below: class RegistrationForm(forms.Form): username = forms.RegexField(label=("Username"), max_length=30, regex=r'^\w+$', help_text = ("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."), error_message =("This value must contain only letters, numbers and underscores.")) email = forms.EmailField(label=("e-mail")) password1 = forms.CharField(label=("password"), widget=forms.PasswordInput) password2 = forms.CharField(label=("re-enter password"), widget=forms.PasswordInput)
def clean_password2(self): if 'password1' in self.cleaned_data: password1 = self.cleaned_data['password1'] password2 = self.cleaned_data['password2'] if password1 == password2: return password2 raise forms.ValidationError("The two password fields didn't match.") return password2 and my view as per below: def register(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): user = User.objects.create_user( username = form.cleaned_data['username'], email = form.cleaned_data['email'], password = form.cleaned_data['password1'] ) return render_to_response('success.html') else: form = RegistrationForm() variables = RequestContext (request,{'form':form}) return render_to_response('register.html', variables) somebody please give me clue and thank you in advance regards, -vierda- --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---