User object is not the user, must update at the user (#254)

修改信息保存后数据不是最新的而是之前的数据,因为在object的惰性查询不会获取到最新的数据,因此需要在缓存的对象基础上修改save后commit到数据库。
pull/256/head
lrqrun 2016-06-07 10:55:28 +08:00 committed by ibuler
parent f130a78f0a
commit b7be5d14e0
1 changed files with 3 additions and 1 deletions

View File

@ -419,7 +419,9 @@ def change_info(request):
error = '不能为空'
if not error:
User.objects.filter(id=user_id).update(name=name, email=email)
user.name = name
user.email = email
user.save()
if len(password) > 0:
user.set_password(password)
user.save()