コード例 #1
0
ファイル: views.py プロジェクト: bretanac93/stackboom
def create_answer(request, question_id):
    ans = Answer()
    ans.question = Question.objects.get(pk=question_id)
    ans.author = request.user
    ans.content = request.POST['content']
    ans.is_better = False
    ans.save()
    return HttpResponseRedirect(reverse('question-details', args=(question_id,)))
コード例 #2
0
ファイル: views.py プロジェクト: chennanxu/Lingxi-1
def deal_with_answer(request, question):
    form = AnswerForm(request.POST)
    print('arrive deal_with_answer')
    if form.is_valid():
        answer = form.cleaned_data['answer']
        c = Answer(answerer=request.user.profile, belong_to_question=question)
        c.content = answer
        c.save()
        return AnswerForm
    else:
        return form
コード例 #3
0
ファイル: answers.py プロジェクト: nginth/interviewdb-api
def answer_from_json(json):
    answer = Answer()
    answer.content = json['content']
    answer.question_id = json['questionId']
    return answer