我有以下视图,在保存之前将一个图像字段保存到另一个图像字段:
if request.method == 'POST':
form = PlayerForm(request.POST, request.FILES, instance=current_player)
if form.is_valid():
temp_image = form.cleaned_data['profile_image2']
form.cleaned_data['profile_image'] = temp_image
form.profile_image = temp_image
form.save()
return redirect('player')
问题是图像无法保存。我用boto作为后端。我不确定这是否与此有关。在
如何将临时图像保存到配置文件映像?在
我想您可能需要先将表单保存到模型中,然后再更新
profile_image
:你的代码让我有点困惑。{{1}你把它理解成是从cd1}得到的吗?如果这就是你正在尝试的,那么这是一个可能的答案:
[这里是初学者,所以可能会有一个小错误,但如果我在做你正在做的事情,那就是我将如何着手解决这个问题]
相关问题 更多 >
编程相关推荐