title: how do i validate unique mobile number in the seller model in Django
body: <p>I am trying to validate mobileno(unique) of model seller.
  but it giving me error and not doing desired task.<br>
  What should I do so that uniqueness of mobileno is checked in the forms?<br>
  Following is my model.py:  </p>
  
  <pre><code>    class Seller(models.Model):
      mobilenno = models.DecimalField(max_digits=10, decimal_places=0, unique=True)  # Field name made lowercase.
      password = models.CharField(max_length=64)
      name = models.CharField( max_length=64)
    #  city = models.ForeignKey(City)
      address = models.CharField(max_length=512, blank=True, null=True)  # Field name made lowercase.
      phoneno = models.DecimalField(max_digits=10, decimal_places=0, blank=True, null=True)  # Field name made lowercase.
  </code></pre>
  
  <p>and form.py</p>
  
  <pre><code>class SellerRegistrationForm(forms.Form):
  
      mobileno1 = forms.DecimalField(widget=forms.TextInput(attrs=dict(required=True, max_length=30)),
                                    max_digits=10, decimal_places=0,label=_("Mobile Number"))
      password1 = forms.CharField(widget=forms.PasswordInput(attrs=dict(required=True, max_length=30, render_value=False)),
                                  label=_("Password"))
      password2 = forms.CharField(widget=forms.PasswordInput(attrs=dict(required=True, max_length=30, render_value=False)),
                                  label=_("Password (again)"))
      name = forms.CharField(widget=forms.TextInput(attrs=dict(required=True, max_length=30)),
                                   label=_("Seller Name"))
      address = forms.CharField(widget=forms.TextInput(attrs=dict(required=True, max_length=30)),
                                   label=_("Seller Address"))
      phoneno = forms.DecimalField(widget=forms.TextInput(attrs=dict(required=True, max_length=30)),
                                   max_digits=10, decimal_places=0, label=_("Phone Number"))
  
      def clean_mobileno1(self):
  
          try:
              Seller.objects.get(mobileno=self.cleaned_data['mobileno1'])
          except Seller.DoesNotExist:
              return self.cleaned_data['mobileno1']
          raise forms.ValidationError(_("The mobilenumber already exists. Please try another one."))
  
      def clean(self):
          if 'password1' in self.cleaned_data and 'password2' in self.cleaned_data:
              if self.cleaned_data['password1'] != self.cleaned_data['password2']:
                  raise forms.ValidationError(_("The two password fields did not match."))
          return self.cleaned_data
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>def seller_register(request):
      if request.method == 'POST':
          form = SellerRegistrationForm(request.POST)
          if form.is_valid():
              Seller.objects.create(
                  mobilenno=form.cleaned_data['mobileno1'],
                  password=form.cleaned_data['password1'],
                  name=form.cleaned_data['name'],
                  address=form.cleaned_data['address'],
                  phoneno=form.cleaned_data['phoneno']
              )
              return HttpResponseRedirect('/register/success/')
      else:
          form = SellerRegistrationForm()
  
      return render(request,'registration/register.html', {'form': form })
  </code></pre>