Pass user replies across different pages
<p>I'd like to create a small web application with Django.</p>

<p>It's about different questions: I have ~20 questions/statements that can be answered with "Agree"/"Don't agree"/"Neutral". Now I need a way to pass the data because at the end, when the user has answered all questions I have to analyse the input.</p>

<p>But I don't know what's the best way to save the data across the different pages/questions. I guess <a href="https://django-formtools.readthedocs.io/en/latest/wizard.html#how-it-works" rel="nofollow">Form wizard</a> could be a good idea. How many questions I have is saved in the database.</p>

<p>But I don't know how to create one <code>Form</code> class for every question dynamically. It would be nonsense to hardcode the form like <a href="https://django-formtools.readthedocs.io/en/latest/wizard.html#defining-form-classes" rel="nofollow">here</a>.</p>

<p>So, is there a way how I can use it and depening on how many questions are in the database, more or less <code>Form</code> classes get created?</p>

<p>Or do you have a whole different solution for my problem?</p>

<p>I've accomplished this by having all questions be part of the same form, but hiding all questions except for the current one using Javascript. It'd look something like this:
1) Render the form with a class that gives all questions "display: none" except for the first one. 
2) Have "Previous" and "Next" buttons that doesn't submit, but rather hide the current question and move on to the next/previous.
3) If someone clicks "Next" on the second-to-last question, display the last question and also replace the "Next" button with a "Submit" button.</p>

<p>This approach has the advantage of making you not need to worry about pagination on the server side, and also avoids multiple saves (in case form validation, database queries, or data processing times are an issue)</p>

<p>If you need to process and re-process questions before giving out the next ones, the approach I've suggested might not be ideal. But otherwise, I think this approach might work nicely. </p>

python django