UserChangeForm does not handle username changes well
|Reported by:||Lacrymology||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
When using UserChangeForm to change the logged in user's username, it changes the instance's username (and any other data changed) to the requested value until the next request. This doesn't change the database, but it does make the response template use the wrong username on this request's render.
this is caused by ModelForm's build_instance when the form was created with an
kwarg, which is called before checking for uniqueness.
In general, it doesn't seem that the UserChangeForm handles failure very well when the instance kwarg is set.