Following works fine in shell:
>>> from django.contrib.auth.models import User
>>> user=User.objects.get(pk=1)
>>> user.first_name = u
if request.method == "POST":
kwargs = { 'data' : request.POST }
try:
kwargs['instance'] = User.objects.get(username=request.POST['username'])
except:
pass
form = UserForm(kwargs**)
if form.is_valid():
user = form.save(commit=False)
...
Just add on request.method == 'post' branch this:
form = UserForm(data=request.POST, instance=request.user)