alueError:无法分配值字段必须是对象实例 [英] alueError: Cannot assign value-field-must-be-a-object-instance

查看:32
本文介绍了alueError:无法分配值字段必须是对象实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误

ValueError: Cannot assign "(<UP:testUser>, True)": "C.pI" must be a "UP" instance.

推荐答案

返回元组:

profile, _ = UserProfile.objects.update_or_create(gender = 'F',
                                           defaults={
                                           'user': user})

profile 是您的用户,_ 是布尔值(如果它是创建或更新的).

profile is your user, _ is boolean if it was created or updated.

这篇关于alueError:无法分配值字段必须是对象实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆