environment Python 3.5.0 Django 1.9.2
forms.py
CAKE_CHOICES = (
(1, 'Strawberry cake'),
(2, 'Chocolate cake'),
(3, 'Cheesecake')
)
class CakeForm(forms.Form):
medal = ChoiceField(widget=Select, choices=MEDAL_CHOICES)
class Meta:
model = Cake
views.py
cake_form = CakeForm(initial = {
'selected_cake': 2 #Set chocolate cake to default
})
Recommended Posts