def SubmitAnswerHandler (request): params = {} if request.method == 'GET': params = request.GET elif request.method == 'POST': params = request.POST questionID = params ["qid"] question = Question.objects.get(qid = questionID) ans = Answer(userid = str(params["user"]), answer = str(params["answer"]), qid = question) ans.save() args = dict(qid = questionID) t = loader.get_template('answerpost-submit.html') c = RequestContext(request, args) return HttpResponse(t.render(c))
def SubmitAnswerHandler (request): postParams = request.POST getParams = request.GET print postParams print getParams # Get the Question ID questionID = getParams["qid"] print questionID # Get the Question q = Question.objects.get(qid = questionID) print q # Create the Answer and Save it in the DB ans = Answer(qid = q, answer = postParams ["answer"], userid = request.user.id, username = request.user.username) ans.save() args = dict(msg = "Answer Successfully Submitted!", qid = questionID) return HttpResponseRedirect("showQuestion?qid=" + args["qid"] + "&submit=true")