Re: Forms: custom clean for DateField

2009-03-19 Thread johan . uhle
> if (data['firstDate'] >= data['lastDate']): > raise ValidationError("Error") it should read raise forms.ValidationError If you want to have the error not only as a non_field global error, but actually added to the fields where the error occured, you can do the following in

Re: Forms: custom clean for DateField

2009-03-18 Thread Wim Feijen
Hi Marco, In Django 1.0, you don't need to call clean from clean, Django will do that automatically for you. :) So what you can do is: def clean(self): data = self.cleaned_data if (data['firstDate'] >= data['lastDate']): raise ValidationError("Error")

Re: Forms: custom clean for DateField

2009-03-06 Thread MarcoS
Sorry, i've posted without finishing the message :) So, if I call clean(self), Django give me this exception for the following line: super(forms.DateField, self).clean() Exception Type: TypeError Exception Value: super(type, obj): obj must be an instance or subtype of type

Forms: custom clean for DateField

2009-03-06 Thread MarcoS
Hi all, I've some difficulties in a custom clean function in the following form: class SelectDateForm(forms.Form): firstDate = forms.DateField(widget=AdminDateWidget) lastDate = forms.DateField(widget=AdminDateWidget) 'cause I want to check if firstDate is minor than lastDate (and obviou