environnement Python 3.5.0 Django 1.9.2
forms.py
CAKE_CHOICES = (
(1, 'gâteau aux fraises'),
(2, 'Gateau au chocolat'),
(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 #Définir le gâteau au chocolat par défaut
})
Recommended Posts