I'm working on a django 1.4.5. I added to the model, select the size of T-shirts.
Field in my model
tshirt_size = models.CharField(choices=TSHIRT_SIZE_CHOICES, default="s", blank=True, null=True, max_length=24)
My form
class SubscriberForm(forms.ModelForm):
class Meta():
model = Subscriber
exclude = ['event', 'is_active']
widgets = {
'name': TextInput(),
'last_name': TextInput(),
'email': TextInput(),
'tshirt_size': Select(choices=TSHIRT_SIZE_CHOICES)
}
In view, I get data in this way:
tshirt_size = request.POST.get('tshirt_size')
Part of html code
<label for="id_tshirt_size">T-Shirt Size (Unisex):</label>
{{ form.tshirt_size }}
And when I execute save on form I get in admin panel None value for tshirt_size.
Aucun commentaire:
Enregistrer un commentaire