Обработка во views
def choice(request, test_id):
test = get_object_or_404(Test, id=test_id)
questions = Question.objects.all().filter(test=test)
question = questions.order_by("id")[0]
answers = Answer.objects.all().filter(question=question)
form = AnswerForm(question=question)
if request.method == "POST":
value = request.POST
answer = value.get("answer")
answerss = get_object_or_404(Answer, id=answer)
if answerss.truth == True:
Answer.votes_true = +1
context = {"test": test, "question": question, "answer": answers, "form": form}
return render(request, "assay/test.html", context)
В строке question = questions.order_by("id")[0]
я выбираю первый вопрос, заданного теста. На страницу выводится данный вопрос и форма с вариантами ответов. Как мне после POST запроса, перейти ко второму вопросу и т.д до конца всех вопросов?
Источник: Stack Overflow на русском