多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC=1,5] >[success] # widget自带的属性 >[danger] ##### attrs设置属性 `name = forms.TextInput(attrs={'size': 10, 'title': 'Your name',})` * 效果展示 `'<input title="Your name" type="text" name="name" value="A name" size="10" required />'` ~~~ user = fields.CharField( widget = widgets.Select(attrs={'class':'tss'}) ) ~~~ >[success] # widgets. 的方法 >[danger] ##### widgets. TextInput 文本输入框 ~~~ input_type:'text' template_name:'django/forms/widgets/text.html' 呈现为:< input type =“text” ...>; ~~~ >[danger] ##### widgets. PasswordInput密码本输入框 ~~~ input_type:'text' template_name:'django/forms/widgets/text.html' 呈现为:< input type =“text” ...>; ~~~ >[danger] ##### widgets. HiddenInput 输入隐藏 ~~~ input_type:'hidden' template_name:'django/forms/widgets/hidden.html' 呈现为:&lt; input type =“hidden” ...&gt; ~~~ >[danger] ##### widgets. Textarea长文本 ~~~ template_name:'django/forms/widgets/textarea.html' 呈现为:<textarea>...</textarea> ~~~ >[danger] ##### widgets. CheckboxInput Checkbox ~~~ input_type:'checkbox' template_name:'django/forms/widgets/checkbox.html' 呈现为:&lt; input type =“checkbox” ...&gt; 一个可调用的对象,接收CheckboxInput 的值并如果复选框应该勾上返回True。 ~~~ >[danger] ##### widgets. Select ~~~ template_name:'django/forms/widgets/select.html' option_template_name:'django/forms/widgets/select_option.html' 呈现为:&lt; select&gt;&lt; option ...&gt; ...&lt; / select&gt; ~~~ >[danger] ##### RadioSelect 单选 ~~~ template_name:'django/forms/widgets/radio.html' option_template_name:'django/forms/widgets/radio_option.html' ~~~ >[danger] ##### SelectMultiple 多选 ~~~ template_name:'django/forms/widgets/select.html' option_template_name:'django/forms/widgets/select_option.html' 与Select类似,但允许多个选择:&lt; select multiple =“multiple”&gt; ...&lt; / select&gt; t5 > T3> ~~~ >[danger] ##### FileInput 文件上传 ~~~ template_name:'django/forms/widgets/file.html' 呈现为:&lt; input type =“file” ...&gt; ~~~