author | nishanth |
Wed, 21 Apr 2010 19:39:19 +0530 | |
changeset 36 | 9e0d6aecf269 |
parent 12 | 81cd0140a0f2 |
child 62 | baddb55f8da7 |
permissions | -rw-r--r-- |
from django import forms from offline.event.models import Event class EventCreateForm(forms.ModelForm): class Meta: model = Event fields = ['title', 'start_date', 'stop_date'] def clean_start_date(self): return self.cleaned_data['start_date'] def clean_stop_date(self): stop_date = self.cleaned_data['stop_date'] start_date = self.clean_start_date() if start_date > stop_date: raise forms.ValidationError("Event cannot stop before it starts") return self.cleaned_data['stop_date']