python - Django: get and use multiple results, by using return HttpResponse( , , , ,) from a form -
i tried searching lot. couldn't find appropriate answer. asking here. please kindly me, tell me if wrong or using wrong approach. suggest me better approach , pls tell me mistake.
can multiple values using........
return httpresponse(text1, text2, text3)
result = text1+ text2+ ....... return httpresponse(result) #(without using concatination)
here code
def post_form(request): return render(request, 'post.html') def postresult(request): if 'fname' in request.post: message = 'welcome : %s' % request.post['fname'] message2 = 'book %s' % request.post['book'] message3 = 'description of book : %s' % request.post['desc'] message4 = 'book %s' % request.post['book'] # message5 = 'liked or unlikd article: %s ' % request.post['like'] # result = message + message2 + message3 + message4 + message5 return httpresponse(message, message2, message3, message4) else: message = 'you submitted empty form.' return httpresponse(message)
you can send many parameters want. follow these steps:
import json def post_form(request): data_details = {'key1' : 'value1', 'key2' : 'value2', 'key3' : 'value3'} return httpresponse(json.dumps(data_details))
you need convert json
Comments
Post a Comment