0
調用一個另一個函數內的views.py財產以後這樣Django的從一個視圖函數
def getFormValues(request):
if ('mobile_a' in request.GET and request.GET['mobile_a']) and ('mobile_b' in request.GET and request.GET['mobile_b']):
mobile_a = request.GET['mobile_a']
mobile_b =request.GET['mobile_b']
# calling the mark calculation function
return calculateMark(mobile_a, mobile_b)
else:
message ='You submitted an empty form.'
return HttpResponse(message)
在這裏,我調用一個函數(calculateMark),這將計算的標記。在calculateMark函數結束時,我有這樣的事情
if (tech_mark_a == 0 and tech_mark_b == 0):
mobile_a_infos = TechSpecificationAdd.objects.filter(tech_variables)
return render_to_response('degrees_result.html', {'mobile_a': tech_mark_a, 'mobile_b': mobile_b}, mobile_a_infos)
elif (tech_mark_a > 0 and tech_mark_b > 0):
return render_to_response('degrees_result.html', {'mobile_a': tech_mark_a, 'mobile_b': mobile_b})
問題是,當我提出一個空的表格它顯示消息getFormValues()。但是當我在表單上提交一些內容時,它顯示錯誤。視圖MarkCalculation.views.getFormValues沒有返回HttpResponse對象。 我該如何解決問題?提前致謝。
感謝您的回答。你能否詳細說明這個程序,我該怎麼辦? –
**提示:'calculateMark(0,25); calculateMark(-3,4)'** –
謝謝它已經解決了。 calculateMark()函數中有一個愚蠢的錯誤。 –