Now I know it use forms.Select(),however I add attrs whth class ,but it doesn't work!
在 2017年8月1日星期二 UTC+8上午10:59:12,李余通写道:
-- Gategory = ModelChoiceField(queryset=GoodsType.objects.all())
widgets = {
'Gategory' : forms.Select(attrs={'class' : "form-control",
}),
}
-->>>
<select id="id_Category" name="Category">\n<option value="" selected="selected">---------</option>\n<option value="1">\u5168\u90e8</option>\n<option value="2">\U0001f436</option>\n</select>
在 2017年8月1日星期二 UTC+8上午10:59:12,李余通写道:
Hello,Everyone,
I know charField can useforms.TextInput(attrs={'class' : 'form-control',
}),
or
forms.Textarea(attrs={'class' : "form-control",
'rows' : 3 ,
})
to set widgets
but ModelChoiceField?
I have no idea,Django telled me "'module' object has no attribute 'ChoiceInput'"
when i use
forms.ChoiceInput
and "__init__() got an unexpected keyword argument 'attrs'" when i use ModelChoiceField
Can you help me?
Thank you very much?
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3728c5f6-723f-4896-a897-4beb7c4b4747%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment