2017-04-04 68 views

回答

0

我不知道是什麼runAreaReview(param)應該返回,但假設它會返回的字符串,例如,那麼這應該工作:

from django.http import HttpResponse 

def result(request): 
    param = ... 
    this = ...' 
    return HttpResponse(this) 
1

A view function, or view for short, is simply a Python function that takes a Web request and returns a Web response. Each view function is responsible for returning an HttpResponse object.

在你的代碼中,你只是返回一個值而不是HttpResponse。正確的代碼將是:

from django.http import HttpResponse 
def result(request): 
    if request=="POST": 
     return HttpResponse("something you want to view") 
+0

我將代碼更改爲「返回HttpResponse」,但我仍然收到錯誤。 –

+0

對於測試:我加 返回HttpResponse(「測試」) 但現在拋出的錯誤是:AttributeError:'NoneType'對象沒有屬性'split –

+0

哪個django版本你當前在你的項目中使用? – orvi