On Mon, 2009-04-06 at 23:58 -0700, Harish wrote: [...] > If salary is found negative it displays the error message in beginning > of the form(that is after the message 'Please correct the error below. > '). Actually it should display the error message in the 'Salary' > section > > I think, I am missing something here.
Since your field validation appears to only depend on the "salary" form field, the easiest solution here is to write a clean_salary() method, rather than using clean(). Then, any ValidationError raised will automatically be assigned to the salary field. Have a look at http://docs.djangoproject.com/en/dev/ref/forms/validation/#cleaning-a-specific-field-attribute and the surrounding documentation for some more information about this. In general, the clean() method is only useful if you're validating multiple fields simultaneously to check something. When the result of a particular check only depends on a single field, best to validate as part of that field's cleaning routine. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---