Answer the question
In order to leave comments, you need to log in
How can a class be added to a django form field?
from django import forms
PAYMENT_METHOD_CHOICE=(
('Наличные', 'Наличными курьеру'),
('Картой', 'Оплата картой на сайте')
)
PERSON_COUNT_CHOICE=[(i, str(i)) for i in range(1, 6)]
class SendForm(forms.Form):
name = forms.CharField(max_length=25)
number = forms.CharField(max_length=25)
street = forms.CharField(max_length=200)
house = forms.CharField(max_length=100)
entrance = forms.IntegerField(required=False)
corps = forms.IntegerField(required=False)
floor=forms.IntegerField(required=False)
payment_method = forms.ChoiceField(choices=PAYMENT_METHOD_CHOICE, widget=forms.RadioSelect())
surrender = forms.DecimalField(required=False)
person_count = forms.TypedChoiceField(choices=PERSON_COUNT_CHOICE, coerce=int)
comments = forms.CharField(required=False,
widget=forms.Textarea)
Answer the question
In order to leave comments, you need to log in
There are several solutions and everything is in the documentation
Here is a link to the implementation , maybe it will help someone
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question