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))
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))