I m building quiz app I have 3 models ( Quiz, Question,Answers) Question foreign key with Quiz,and Answee foreign key with Questions. I m successful in showing each question on separate page according to their pk. But to redirect from one question to another until last question
Asked
Active
Viewed 27 times
1 Answers
0
Most likely, you have to do something like this in your view:
def answer(request):
# here should be code to handle answer
question = Question.objects.get(pk=request.POST['id'])
quiz = question.quiz
later_question = Question.objects.filter(quiz_id=quiz.id, question_id__gt=question.id).first()
if later_question:
# redirect to later question
else:
# no later question, end the quiz

Alex Antonov
- 14,134
- 7
- 65
- 142