0
我recieving以下錯誤提交表單時不返回一個HttpResponse對象,我真的不能明白爲什麼:Django的:查看「沒有返回HttpResponse對象」
Exception Type: ValueError at /contact/addcontact
Exception Value: The view openshift.contactapplication.views.contact didn't return an HttpResponse object.
這是我的看法:
# Create your views here.
from django.shortcuts import render_to_response, render
from django.http import HttpResponseRedirect, HttpResponse
#forms imports
from contactapplication.forms import applicantsForm
#model imports
from contactapplication.models import applicantsModel
def contact(request):
if request.method == 'POST':
form = applicantsForm(request.POST)
if form.is_valid():
clean_form =form.cleaned_data
collect = applicantsModel(first_name=clean_form['first_name'], last_name=clean_form['last_name'],
linkedin_profile=clean_form['linkedin_profile'], elevator_pitch=clean_form['elevator_pitch'],
email=clean_form['email'], phone=clean_form['phone'])
collect.save()
return HttpResponseRedirect('contactUs/contactUs.html') #the same page, change to thankyou page later
else:
return render(request, 'contactUs/contactUs.html',)
可能是什麼問題?我清楚地返回了HttpResponseRedirect
感謝您指出,非常感謝。是的,你閱讀正確。 – ApathyBear