Guest User

Untitled

a guest
Feb 8th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. class CommentForm(forms.ModelForm):
  2.     class Meta:
  3.         model = Comment
  4.         fields = ('text',)
  5.  
  6.     text = forms.CharField(widget=forms.Textarea)
  7.  
  8.     def clean(self):
  9.         text = self.cleaned_data['text']
  10.         if len(text) < 5:
  11.             raise forms.ValidationError('No, sorry')
  12.         else:
  13.             return self.cleaned_data
Add Comment
Please, Sign In to add comment