﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
12896	ModelForm.is_valid() and ModelForm.errors have backwards-incompatible side effects since model validation	Luke Plant	jkocherhans	"Since r12098 (model validation merge), `ModelForm.is_valid()` and `ModelForm.errors` have the side effect of modifying the bound instance.

Attached is a (rather lazily written) patch to the tests which demonstrates the problem - it ought to pass, and does pass before r12098 (noting that the patch doesn't apply cleanly before r12098), but not after.

This is a significant backwards incompatibility, but rather subtle too - in my case it was caught only due to fairly extensive tests in one of my projects.  It is also quite counter-intuitive that either `form.errors` or `form.is_valid` should have any side effects.  At the very least this needs to be clearly documented.  I'm guessing it might be tricky to fix, given earlier problems surrounding the order of events in model validation.

For your information, my use case is detecting that a change has occurred to a certain field:
{{{
#!python
if form.is_valid():
    orig_val = obj.val
    obj = form.save()
    if obj.val != orig_val:
        do_something()
}}}

The side effects of `form.is_valid()` mean that `do_something()` is no longer called."		closed	Forms	1.1		fixed			Design decision needed	0	0	0	0	0	0
