# HG changeset patch # User nishanth # Date 1267524291 -19800 # Node ID 106909df0c1747197ed3d902e8efeb2707e109b1 # Parent 4a7206176345bcaf82f24038a27607be1aa3ff65 empty description for a task not allowed. white space around description trimmed. diff -r 4a7206176345 -r 106909df0c17 taskapp/forms/task.py --- a/taskapp/forms/task.py Tue Mar 02 15:21:45 2010 +0530 +++ b/taskapp/forms/task.py Tue Mar 02 15:34:51 2010 +0530 @@ -7,11 +7,26 @@ fields = ['title', 'desc', 'tags_field', 'credits'] #publish = forms.BooleanField(required=False) + def clean_desc(self): + data = self.cleaned_data['desc'].strip() + if not data: + raise forms.ValidationError("Enter some description for the task") + + return data + def EditTaskForm(task, instance=None): class myForm(forms.ModelForm): class Meta: model = Task fields = ['title', 'desc', 'tags_field', 'credits'] + + def clean_desc(self): + data = self.cleaned_data['desc'].strip() + if not data: + raise forms.ValidationError("Enter some description for the task") + + return data + data = { 'title': task.title, 'desc': task.desc,