def long_test_form(request): if request.method=="POST": question_text=request.POST['question_text'] long_text = request.POST['long'] q=Question() q.long_text=long_text q.question_text=question_text q.pub_date = datetime.now() q.save() return HttpResponseRedirect(reverse('detail', args=(q.id,))) return render(request, "main/form.html",{})
def details(request): try: selected_choice = request.POST['choice'] pub_date_selected = request.POST['pub_date'] author_selected = request.POST['author'] except (KeyError, Choice.DoesNotExist): selected_choice = '' pub_date_selected = '2018-08-08' author_selected = '' q = Question() q.question_text = selected_choice q.pub_date = pub_date_selected q.author = author_selected q.save() return render(request, 'main/details.html', {'selected_choice': selected_choice})