On Thursday, April 21, 2011 8:16:36 AM UTC+1, Constantine wrote: > > Hi > > i've used some logic in clean_field methods, but when i've migrated to > ModelForm, was very surprised that clean methods does not invoked > after some investigation i realized that model instane does not makes > modelform bound automatically > > i'm expect that model validation also triggered as pointed here > > http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-is-valid-method-and-errors > > but models.py contradicts > def is_valid(self): > """ > Returns True if the form has no errors. Otherwise, False. If > errors are > being ignored, returns False. > """ > return self.is_bound and not bool(self.errors) > > model with instance only WILL NOT trigger validation >
I'm not sure why that would surprise you, or why you would want it to work any other way. Form validation is for validating user input, not for checking already-saved instances (which presumably are already valid, otherwise they should not have been saved). -- DR. -- 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.