def create_question(request, story): f = QuestionCreateForm(request.POST) if f.is_valid(): o = f.save(commit=False) o.story = story o.user = request.user o.save() return JSONResponse({'result': render_to_string('lqa/_question.html', {'question': o})}) else: return JSONResponse({'form': as_crispy_form(f)})
def edit_question(request, story, question_id): q = Question.objects.get(id=question_id) f = QuestionCreateForm(request.POST, instance=q) if f.is_valid(): o = f.save(commit=False) o.story = story o.user = request.user o.save() return JSONResponse({'result': render_to_string('lqa/_question.html', {'question': o})}) else: return JSONResponse({'form': as_crispy_form(f)})
def create_question(request, story): f = QuestionCreateForm(request.POST) if f.is_valid(): o = f.save(commit=False) o.story = story o.user = request.user o.save() return JSONResponse({ 'result': render_to_string('lqa/_question.html', {'question': o}) }) else: return JSONResponse({'form': as_crispy_form(f)})
def edit_question(request, story, question_id): q = Question.objects.get(id=question_id) f = QuestionCreateForm(request.POST, instance=q) if f.is_valid(): o = f.save(commit=False) o.story = story o.user = request.user o.save() return JSONResponse({ 'result': render_to_string('lqa/_question.html', {'question': o}) }) else: return JSONResponse({'form': as_crispy_form(f)})