I have a Django template that asks for # of players using a html form. I pass this variable to the views.py which renders to another template (including the # of players).
The next template shows the same # of input fields to get the name of the players. Here’s the for loop to iterate through the number of players --
<form action="name_players" method="POST" class="form-inline">
{% csrf_token %}
{% for loop_time in numbers %}
<input name="name_players[]" type="text" class="form-control mb-2 mr-sm-2" id="inlineFormInputName2" placeholder="name of player...">
{% endfor %}
<button type="submit" class="btn btn-primary mb-2">Submit</button>
</form>
How should I go about saving these names in an array and returning to the views.py file and then save to a database OR is there a way to do that directly in the template file. thank you!