class Member(models.Model):
model_categories = models.CharField(
max_length = 255,
null = True,
blank = True)
形式:
class MemberForm(forms.ModelForm):
MODEL_CATEGORIES = (
('advisor', 'advisor'),
('member', 'member'),
('admin', 'admin'),
)
model_categories = forms.MultipleChoiceField(
widget = forms.CheckboxSelectMultiple,
choices = MODEL_CATEGORIES
)
class Meta:
model = Member
fields = [ 'model_categories' ]
不過當我提交表單,它需要現場model_categories
,可以沒有選擇框。是什麼原因 ?