How to update User object without creating new one?

前端 未结 2 1185
时光取名叫无心
时光取名叫无心 2021-02-08 15:06

Following works fine in shell:

>>> from django.contrib.auth.models import User
>>> user=User.objects.get(pk=1)
>>> user.first_name = u         


        
2条回答
  •  轮回少年
    2021-02-08 16:12

    Just add on request.method == 'post' branch this:

    form = UserForm(data=request.POST, instance=request.user)
    

提交回复
热议问题