On Jan 31, 1:19 pm, "MerMer" <[EMAIL PROTECTED]> wrote: > I have a form where a user needs to enter a 8 digit code. I want to > check the user's input against a database and return an error if the > code has already been entered by another user. > > If I use New Forms, do I need to write a custom Field to do this > validation?
No, just implement your clean_YOURFIELDNAME method of the form. class Person(Form): ... (fields declaration follow) def clean_student_seniority(self): if (self.clean_data.get("person_type") == 1) and (self.clean_data.get("student_seniority") == None): raise ValidationError(u"Students must have a seniority defined") return self.clean_data["student_seniority"] Then in your view you check if form.is_valid() Lorenzo --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---