On Tue, Dec 18, 2012 at 4:11 PM, Francisco Vianna < francisco.v.via...@gmail.com> wrote:
> After some debugging, I realized they become the same after calling > "is_valid" to the bound form. Now, I'm not sure if I am missing something > conceptually about ModelForms binding. > Its very ackward to me that I can have a 'instance' field in a ModelForm, > but can't distiguish the data after performing the validation. In my case > specifically, I need to check first if the email provided by the user is > valid, and only then check if its diferent from the instance's e-mail in > order to set my flag. But I can't do it, or I will lose the new e-mail > provided by the user in the form. > > Can anyone enlighten this matter? Is this behavior expected? Yes, is_valid() called on a model form updates the model form's instance in-place with the valid cleaned data. This is documented: https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-is-valid-method-and-errors Your form field's clean method would have access to the "old" value, since that runs before the new value has been fully validated and saved in the instance. Karen -- http://tracey.org/kmt/ -- 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.