The following did it for me: from django import newforms as forms class yourForm(forms.BaseForm): ... def clean(self): "do your custom validation here" return self.cleaned_data
does it for me. Clean is called automatically e.g. by ...is_valid(). hope it helps. jr On Sep 11, 10:19 pm, Mike H <[EMAIL PROTECTED]> wrote: > Hi all, > > I have a model which needs some non-standard checks before it gets saved. > The class looks like this : > > class Page(models.Model): > name = models.CharField(maxlength=30) > content = models.TextField() > start_date = models.DateField() > end_date = models.DateField() > > When I save the model, I want to check that there is no other page with > the same name that has an overlapping start and end date, and cause some > kind of validation error that the admin area will display. > > I have tried the following : > > def save(self): > # check for the overlap happens here > .... > # if the check fails... > raise validators.ValidationError(_("A page with this name > already exists in the time period specified")) > > However, the admin area does not catch the exception. I've looked > through the djangobook which references a chapter that isn't there yet, > and the online documentation points to a .validate() on the model which > is marked as experimental. If it's possible, where can I put custom > validation like that, that the admin area will pick up on? I'm currently > using 0.96 but could easily upgrade to the svn trunk if needed. > > Thanks for any help, > > Mike --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---