【发布时间】:2021-11-20 07:05:57
【问题描述】:
我有一个 user 和 user_profile 模型,并且我允许使用可为空的字段进行注册,因此用户可以稍后填写个人资料,但我希望应用程序在每次登录后检查是否有任何个人资料字段为空。是否可以循环浏览django模型对象字段?
我尝试了下面的代码并得到'uProfile is not iterable'
def profile_Populated(usr):
for x in usr:
if x == 'null':
return False
return True
if profile_Populated(request.user.uProfile) == True:
pass
else:
return redirect("account:profile_edit")
【问题讨论】:
标签: django