I'm new to django and would like to create a drop down menu for options. I'm confused as to what I should include in my forms.py and how to call that form on my index.html.
My forms.py
from django import forms
class MyModel2(forms.Form):
class Meta:
model = MyModel
fields = ['color']
My index.html
<form method="POST" action = "">{% csrf_token %}
<p>Choose color</p> {{ form.color}}
<br><br>
<input type="submit" value="Submit!"/>
</form>
My models.py
from __future__ import unicode_literals
from django.db import models
COLOR_CHOICES = (
('green','GREEN'),
('blue', 'BLUE'),
('red','RED'),
('orange','ORANGE'),
('black','BLACK'),
)
class MyModel(models.Model):
color = models.CharField(max_length=6, choices=COLOR_CHOICES, default='green')
Thank you!