0

I am doing quiz app. I want questions to appear on one page but by one. For example, we have 5 questions. I see the first of them, answer this and only after that I can see the next one and the previous one disappears. How to do it? Plz I need help. It is really important. Thanks everyone!

1 Answers1

0

Note: This is one of the many possible solutions. Django gives you a whole toolset to return question id's and redirect users etc.

The way to think about this problem is by asking how the front-end will ask django what question to return. In this case I would go with url-encoded data.

You could add an url-encoded question counter which is passed to your view function where you can then just output the question with that particular id which is queried from the url.

You can parse url encoded data using the method described here: How to get request parameters from an encoded URL in Django?

You would just add a button with the next question id as url.

So:

https://example.com/question?id=0

request.GET.get("id")

will return 0 which can be the first question, and add the following href in the "next" button on the webpage:

https://example.com/question?id=1

which return the next question and so on.