Example #1
0
def create_question(request):
    if request.method == "GET":
        form = QuestionForm()
        return render_to_response("app/questions/create.html", {'form':form},  RequestContext(request,{ 'title': 'Create new question' }))
    elif request.method == 'POST':
        user = request.user.userprofile

        form = QuestionForm(request.POST)
        question_services = QuestionServices()
        question = question_services.create_question(form.data['title'], form.data['body'], user)
        return HttpResponseRedirect('/question/' + str(question.id))
Example #2
0
def create_question(request):
    if request.method == "GET":
        form = QuestionForm()
        return render_to_response(
            "app/questions/create.html", {'form': form},
            RequestContext(request, {'title': 'Create new question'}))
    elif request.method == 'POST':
        user = request.user.userprofile

        form = QuestionForm(request.POST)
        question_services = QuestionServices()
        question = question_services.create_question(form.data['title'],
                                                     form.data['body'], user)
        return HttpResponseRedirect('/question/' + str(question.id))