title: Password Validation error in django 1.6
body: <p>Trying to create password validation for a django application, but one problem that is persisting is in my clean_password function in forms.py, when I am testing(Using the UI form in the template) and entire matching passwords, I still raise the error message "Password does not match". Any clue to what I am doing wrong?</p>
  
  <p><strong>forms.py:</strong></p>
  
  <pre><code>#coding=utf-8
  from django import forms
  from django.contrib.auth.models import User
  from django.utils.translation import ugettext_lazy as _
  from django.forms import extras
  import time
  from models import ProfileUser
  
  now=time.localtime()
  
  ###### Login for users ###########
  class LoginForm(forms.Form):
      username=forms.CharField(label=_(u"username"),max_length=30,widget=forms.TextInput(attrs={'size': 20,}))
      password=forms.CharField(label=_(u"password"),max_length=30,widget=forms.PasswordInput(attrs={'size': 20,}))
  
      class Meta:
          """docstring for Meta"""
          model = User
  class RegisterForm(forms.ModelForm):
      email=forms.EmailField(max_length=30, widget=forms.TextInput(attrs={'placeholder': 'Email', 'required':True}))
      username=forms.CharField(max_length=30, widget=forms.TextInput(attrs={'placeholder': 'Username','required':True}))
      password=forms.CharField(max_length=30, widget=forms.PasswordInput(attrs={'placeholder': 'Password','required':True}))
      password2=forms.CharField(max_length=30, widget=forms.PasswordInput(attrs={'placeholder': 'Re-Enter Password','required':True}))
  
  
  
  
      class Meta:
          """ To Specify the fields within User model from django, and to prevent abstraction"""
          model = User
          fields = ('email', 'username', 'password', 'password2')
  
  
      def clean_username(self):
          users = User.objects.filter(username__iexact=self.cleaned_data["username"])
          if not users:
              return self.cleaned_data["username"]
          raise forms.ValidationError("This username already exist")
  
      def clean_email(self):
          emails = User.objects.filter(email__iexact=self.cleaned_data["email"])
          if not emails:
              return self.cleaned_data["email"]
          raise forms.ValidationError("Email is already registered")
  
      def clean_password(self):
          password = self.cleaned_data.get("password")
          password2 = self.cleaned_data.get("password2")
  
          cleaned_data = (password, password2)
  
          if password != password2:
              raise forms.ValidationError("The password does not match ")
  
          return cleaned_data
  </code></pre>
  
  <p><strong>views.py:</strong></p>
  
  <pre><code>#coding=utf-8
  from django.shortcuts import render
  from django.core.urlresolvers import reverse
  from django.http import HttpResponse, HttpResponseRedirect
  from django.shortcuts import render_to_response
  from django.template import RequestContext
  from django.contrib import messages
  from django.contrib.auth.models import User
  from django.contrib.auth import authenticate, login as auth_login ,logout as auth_logout
  from django.utils.translation import ugettext_lazy as _
  from forms import LoginForm, RegisterForm
  from models import ProfileUser
  
  
  ###### Login for users ###########
  def login(request):
      template_var={}
      form = LoginForm()
      if request.method == 'POST':
          form = LoginForm(request.POST.copy())
          if form.is_valid():
              _login(request,form.cleaned_data["username"],form.cleaned_data["password"])
              return HttpResponseRedirect(reverse("login"))
      template_var["form"]=form
      return render_to_response("registration/login.html",template_var,context_instance=RequestContext(request))
  
  
  def _login(request,username,password):
      ret = False
      user = authenticate(username=username,password=password)
      if user:
          if user.is_active:
              auth_login(request,user)
              ret=True
          else:
              messages.add_message(request, messages.INFO, _(u'user is not active'))
      else:
          messages.add_message(request, messages.INFO, _(u'Incorrect username or password'))
      return ret
  
  
  ###### Registration for users ###########
  def register(request):
      template_var={}
      form = RegisterForm()
      if request.method=="POST":
          form=RegisterForm(request.POST.copy())
          if form.is_valid():
              username=form.cleaned_data["username"]
              email=form.cleaned_data["email"]
              password=form.cleaned_data["password"]
              user=User.objects.create_user(username,email,password)
              user.save()
              _login(request,username,password)
              return HttpResponseRedirect("base")
      template_var["form"]=form
      return render_to_response("registration/signup.html",template_var,context_instance=RequestContext(request))
  </code></pre>
  
  <p><strong>Template:</strong></p>
  
  <pre><code>{% extends 'home/base.html' %}
  {% block title %}Signup with Indieitude{% endblock title %}
  
  {% block search %}
  {% endblock search %}
  
  
  {% block space %}
  &lt;div  class="space-registration"&gt;&lt;/div&gt;
  {% endblock space %}
  
  {% block signup %}  
  &lt;div id="content"&gt; 
      &lt;div class="block"&gt;
          &lt;div class="box-login"&gt;
              &lt;div class="head"&gt;
                   &lt;h2 class="heading-title"&gt;Start Discovering&lt;/h2&gt;
  
                  &lt;p align="center"&gt;&lt;em&gt;Log in with your Facebook&lt;/em&gt;
                  &lt;/p&gt;
              &lt;/div&gt;
              &lt;div class="socialconnect"&gt; &lt;a href="#" class="facebook"&gt;Log in with Facebook&lt;/a&gt;
  
              &lt;/div&gt;
              &lt;p align="center"&gt;&lt;em&gt;Or signup with your email &amp; name&lt;/em&gt;
              &lt;/p&gt;
              &lt;div class="box-form"&gt;
                  &lt;form action="" method="post"&gt;{% csrf_token %}
  
  
                      &lt;p&gt;
                          {{form.email}}
                      &lt;/p&gt;
                      &lt;p&gt;
                          {{form.username}}
                      &lt;/p&gt;
                      &lt;p&gt;
                          {{form.password}}
                      &lt;/p&gt;
                      &lt;p&gt;
                          {{form.password2}}
                      &lt;/p&gt;
                      &lt;div class="alerts errorlist"&gt;
                          &lt;span&gt;{{form.username.errors}}&lt;/span&gt;
                          &lt;span&gt;{{form.email.errors}}&lt;/span&gt;  
                          &lt;span&gt;{{form.password.errors}}&lt;/span&gt;   
                      &lt;/div&gt;
                      &lt;p class="agree"&gt;By signing up, I agree to Indieitude's &lt;a href="#"&gt;Terms of Service&lt;/a&gt; &amp; &lt;a href="#"&gt;Privacy Policy&lt;/a&gt;
                      &lt;/p&gt;
                      &lt;p&gt;
                          &lt;input type="submit" name="submit" value="register" class="button large bold"&gt;
                      &lt;/p&gt;
                  &lt;/form&gt;
              &lt;/div&gt;
              &lt;div class="footer"&gt;
                   &lt;h2 class="heading-title" align="center"&gt;Already have an account? &lt;a href="{% url "profiles.views.login" %}"&gt;Login&lt;/a&gt;&lt;/h2&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  {% endblock signup %}  
  </code></pre>