我无法更新扩展的用户个人资料
在views.py中:
def profile(request, user_id):
user = get_object_or_404(User, id=user_id)
user_info = get_object_or_404(UserInfor, user_id=user.id)
if request.method == "POST":
user_form = UserForm(data=request.POST or None, instance=user)
profile_form = ProfileForm(data=request.POST or None, instance=user_info)
user = user_form.save(commit=True)
user_info = profile_form.save(commit=True)
user.save()
user_info.save()
return render(request, 'pages/profile.html', {'user': user_form, 'user_info': profile_form, 'user_id': user_id})
else:
user_form = UserForm(instance=user)
profile_form = ProfileForm(instance=user_info)
return render(request, 'pages/profile.html', {'user': user_form, 'user_info': profile_form, 'user_id': user_id})
如何解决错误?