這是我的觀點:django視圖沒有返回HttpResponse對象。它返回無不是
def GeneralUserPictureChange(request, pk, username):
thumb = GeneralUser.objects.get(pk=pk)
if thumb.username == request.user:
if request.method == 'POST':
form = GeneralUserPictureChangeForm(request.POST, request.FILES)
if form.is_valid():
thumb.thumbnail = form.cleaned_data['thumbnail']
thumb.save()
return redirect("user_profile", pk, username)
else:
return render_to_response("gnu_picture_change.html", {"form":form, "basic_info":thumb}, context_instance=RequestContext(request))
else:
form = GeneralUserPictureChangeForm()
return render_to_response("gnu_picture_change.html", {"form":form, "basic_info":thumb}, context_instance=RequestContext(request))
當我做到這一點給出了錯誤didnt返回HttpResponse對象。但是,當我刪除行 if thumb.username == request.user:
並繼續正確的縮進它不提供錯誤..
需要幫助...
當'如果thumb.username == request.user:'爲true並且代碼朝那個方向運行,會發生什麼? –
問題是如果if爲false時發生了什麼,沒有返回 – AlvaroAV