diff -r 106909df0c17 -r 8d1fdb148c27 taskapp/forms/task.py --- a/taskapp/forms/task.py Tue Mar 02 15:34:51 2010 +0530 +++ b/taskapp/forms/task.py Tue Mar 02 16:04:41 2010 +0530 @@ -7,6 +7,14 @@ fields = ['title', 'desc', 'tags_field', 'credits'] #publish = forms.BooleanField(required=False) + def clean_title(self): + data = self.cleaned_data['title'].strip() + try: + Task.objects.exclude(status="DL").get(title__iexact=data) + raise forms.ValidationError("Another task with same title exists") + except Task.DoesNotExist: + return data + def clean_desc(self): data = self.cleaned_data['desc'].strip() if not data: @@ -27,6 +35,17 @@ return data + def clean_title(self): + data = self.cleaned_data['title'].strip() + try: + prev_task = Task.objects.exclude(status="DL").get(title__iexact=data) + if prev_task != task: + raise forms.ValidationError("Another task with same title exists") + else: + return data + except: + return data + data = { 'title': task.title, 'desc': task.desc,