如何创建一个在复选框右侧显示复选框标签的Django表单
1个回答
展开全部
[python] view plain copy
from django import forms
ACTIVITY_STYLE = (("a", "1"), ("b", "2"), ("c", "3"))
class HobbiesForm(forms.Form):
hobbies = forms.MultipleChoiceField(label=u'活动类型', choices=ACTIVITY_STYLE, widget=forms.CheckboxSelectMultiple())
print HobbiesForm(data={"hobbies": ["a", "b", "c"]}).as_p()
print HobbiesForm(data={"hobbies": ["b", "c"]}).as_p()
from django import forms
ACTIVITY_STYLE = (("a", "1"), ("b", "2"), ("c", "3"))
class HobbiesForm(forms.Form):
hobbies = forms.MultipleChoiceField(label=u'活动类型', choices=ACTIVITY_STYLE, widget=forms.CheckboxSelectMultiple())
print HobbiesForm(data={"hobbies": ["a", "b", "c"]}).as_p()
print HobbiesForm(data={"hobbies": ["b", "c"]}).as_p()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询