Field validation in a Django form
<p>I have a Django form consisting of a email and name field. I want to validate the name to have more than 8 characters. I have used the following code. But it is not working.</p>

<pre><code>class SignUpForm(forms.ModelForm):
    class Meta:
        model=SignUp
        fields=('email','name')
    def emailValidation(self):

        name=self.cleaned_data.get('name')
        if len(name) &lt;=8:
            raise forms.ValidationError("name cannot be less than 8")
</code></pre>

<p>models.py</p>

<pre><code>class SignUp(models.Model):
    name=models.CharField(max_length=200)
    email=models.EmailField()
    timestamp=models.DateTimeField(auto_now_add=True, auto_now=False)
    updated=models.DateTimeField(auto_now=True,auto_now_add=False)
    def __unicode__(self):
        return self.name
</code></pre>

<p>views.py</p>

<pre><code>def home(request):
    form=SignUpForm(request.POST or None)                                           
    if form.is_valid():                                             

        instance=form.save(commit=False)
        instance.save()
        print instance.timestamp
    return render(request, 'home.html',{'form':form})
</code></pre>