After each section, I added an input, in which the user specifies the required number of questions related to a specific section, which would later pull out the required number of questions from the database and display.
Looks like that:

How can I determine to which section (object from the database) does the input belong (chekbox or text)?
Here is the template code
<form action="/vibor_test/gener/" method ="post"> {% csrf_token %} <ol> {% recursetree nodes.get_descendants %} <li> {{ node.name }} {% if node.level == 1 %} <input type="text" name="text" value="" > {% endif %} {% if node.level == 2 %} <input type="checkbox" name="" value=""> {% endif %} {% if not node.is_leaf_node %} <ol class="children"> {{ children}} </ol> {% endif %} </li> {% endrecursetree %} </ol> <input class="button" type="submit" value="Пройти тест"> </form>