# Cant make my template to present drop-down select for modelForm Select field

**URL:** <https://forum.djangoproject.com/t/cant-make-my-template-to-present-drop-down-select-for-modelform-select-field/7431>\
**Category:** Using Django\
**Created:** [April 8, 2021, 1:51pm UTC](https://forum.djangoproject.com/t/cant-make-my-template-to-present-drop-down-select-for-modelform-select-field/7431 "2021-04-08T13:51:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![boaz-g](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/boaz-g/32/4166_2.png) [@boaz-g](https://forum.djangoproject.com/u/boaz-g)\
**Post date:** [April 8, 2021, 1:51pm UTC](https://forum.djangoproject.com/t/cant-make-my-template-to-present-drop-down-select-for-modelform-select-field/7431/1 "2021-04-08T13:51:07Z")

</div>

Hello Respected community  
I am having severe troubles in assembling a working form that should update a record in a Postgres database.  
In the form and before the user clicks submit - i would like to present the user with a drop-down choices widget for Regions. I cant figure out how to make the html template to show the selection drop-down box correctly.  
models.py:

```auto
class SeatsModel(models.Model):
    SUPPORTED_REGIONSS = (
      ('NA', 'North-America'),
      ('LATAM', 'Latin-America'),
      ('APAC', 'Asia, Pacific'),
      ('EMEA', 'Europe, Middle-East and Africa'),
    )
    id = models.IntegerField(primary_key=id)
    account_id = models.IntegerField
    seat = models.CharField(max_length=1024)
    agency = models.CharField(max_length=1024)
    agency_region = models.CharField(max_length=5, choices=SUPPORTED_REGIONSS)
    is_holding_grp = models.BooleanField()
    insert_time = models.DateTimeField()
    update_time = models.DateTimeField(auto_now=True)
    class Meta:
        db_table = 'dim_seats'

```

forms.py:

```auto
class seatform(forms.ModelForm):
    agency_region = forms.ChoiceField(widget=forms.Select(), choices=SeatsModel.SUPPORTED_REGIONSS)

        def __init__ (self, *args, **kwargs):
            super(seatform, self). __init__ (*args, **kwargs)
            self.fields['agency_region'] = forms.ChoiceField(choices=SUPPORTED_REGIONS)

        class Meta:
            model=SeatsModel
            fields = ['agency', 'agency_region', 'is_holding_grp']
'''

views.py

```

```
def updateseat(request, id):
updateseat=SeatsModel.objects.get(id=id)
form=seatform(request.POST, instance=updateseat)
if form.is_valid():
    form.save()
    messages.success(request,'Updated Successfully!')
    return render(request,'editseat.html',{"SeatsModel":updateseat})
else:
    #messages.error(request, 'Invalid values, Update Failed!')
    messages.error(request,form.errors)
    return render(request,'editseat.html',{"SeatsModel":updateseat})

```

```auto
my template (updateseat.html):

```

```
    <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Peer39 - Usage Entity Mapping</title>
</head>
<body>
    <center>
        <h1>Edit Usage Entities</h1>
        <h2>Seat: <b style="color: #1e7e34">{{SeatsModel.seat}}</b></h2>
        <h3>ID: <b style="color: #1e7e34">{{SeatsModel.id}}</b></h3>
        <hr/>

        {% comment %}<form method="post" id="regionsForm" data-regioon-url="{% url 'ajax_load_regions' %}">
            {% csrf_token %}
            {{ form.as_p }}
            <input type="submit" value="Submit">
        </form>{% endcomment %}

        <form method="POST" action="/UpdateSeat/{{SeatsModel.id}}">
            {% csrf_token %}

        <table border="1">
            <tr>
                <td>Seat ID</td>
                <td><input type="text" name="id" value="{{SeatsModel.id}}" style="color:#888;" readonly></td>
            </tr>
            <tr>
                <td>Seat Name</td>
                <td><input type="text" name="seat" value="{{SeatsModel.seat}}" style="color:#888;" readonly></td>
            </tr>
            <tr>
                <td>Agency Name</td>
                <td><input type="text" name="agency" value="{{SeatsModel.agency}}"></td>
            </tr>
            <tr>
                <td>Agency Region no</td>
                <td>
                    <select>
                        <option value="{{ SeatsModel.agency_region }}">{{ SeatsModel.get_agency_region_display }}</option>
                        {% for key, value in seatform.agency_region %}
                        <option value="{{ key }}">{{ value }}</option>
                        {% endfor %}
                    </select>
                </td>
            </tr>
            <tr>
                <td>Is Holding Group</td>
                <td><input type="checkbox" name="is_holding_grp" value="{{SeatsModel.is_holding_grp}}"></td>
            </tr>
            <tr>
                <td><input type="submit" value="Click to Update Seat!"></td>
                <td>
                    {% if messages %}
                    {% for mess in messages %}
                        {% if mess.tags == "error"%}
                        <b style="color: crimson">{{ mess }}</b>
                        {% else %}
                        <b style="color: forestgreen">{{ mess }}</b>
                        {% endif %}
                    {% endfor %}
                    {% endif %}
                </td>
            </tr>

        </table>
        <hr/>
        <a href="{% url 'showseatsview' %}">Go To Seats Page</a>
        </form>
    </center>
</body>
</html>

```

```auto
I will appreciate much if someone can guide on what am i doing wrong.

Thanks !!

Boaz
```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [April 8, 2021, 2:57pm UTC](https://forum.djangoproject.com/t/cant-make-my-template-to-present-drop-down-select-for-modelform-select-field/7431/2 "2021-04-08T14:57:19Z")

</div>

I don’t know if it’s the specific issue here in your template, but you don’t need to render all the options manually - you just render the form field and let Django do the rest.

I suggest you review the [Working with forms](https://docs.djangoproject.com/en/3.1/topics/forms/) docs to see how to work with form in Django, particularly the sections on [templates](https://docs.djangoproject.com/en/3.1/topics/forms/#working-with-form-templates) and [Rendering fields manually](https://docs.djangoproject.com/en/3.1/topics/forms/#rendering-fields-manually).

Also, when posting code (or templates) here, please enclose your code between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This directs the forum software to properly keep your code formatted, which is important for Python. (You can also go back and edit your post to add those ``` lines before and after your code in the original post.)
