I have a django project with a select dropdown. I have typed in the names of players that users can select, but i want to populate the dropdown with the same names but dynamically from the database. How can i go about this?
This is my html so far, not sure how to write the views.py for this, or if i should do a for loop or and if.
<form method="POST">
{% csrf_token %}
<select id="playerselect" name="pitcher" class="player-dropdown">
<option value="{{ pitching.id}}">{{ pitching.player_name }}</option>
<option value="2">Yadiel Lugo</option>
<option value="3">Cody Reeds</option>
<option value="4" >Xavier Colon</option>
<option value="5" >Andy Smith</option>
<option value="6" >Carson Rex</option>
<option value="7" >Jalen Jackson</option>
<option value="8" >Matthew Cobbs</option>
<option value="9" >Matt Sampson</option>
<option value="10" >John Harrison</option>
<option value="11" >Robert Santiago</option>
<option value="12" >Efrain Zuniga</option>
<input type="submit" value="Search"/>
</select>