django_form_widget速查

一、widget自带的属性

  • attrs设置属性

name = forms.TextInput(attrs={'size': 10, 'title': 'Your name',})
效果展示
''

user = fields.CharField(
 widget = widgets.Select(attrs={'class':'tss'})
)

二、widgets. 的方法

  • 文本类型(常用的)

  • widgets. TextInput 文本输入框

input_type:'text'
template_name:'django/forms/widgets/text.html'
呈现为:< input type =“text” ...>;

  • widgets. PasswordInput密码本输入框

input_type:'text'
template_name:'django/forms/widgets/text.html'
呈现为:< input type =“text” ...>;

  • widgets. HiddenInput密码本输入框

input_type:'hidden'
template_name:'django/forms/widgets/hidden.html'
呈现为:&lt; input type =“hidden” ...&gt;

  • widgets. Textarea长文本

template_name:'django/forms/widgets/textarea.html'
呈现为:

  • widgets. CheckboxInput Checkbox

input_type:'checkbox'
template_name:'django/forms/widgets/checkbox.html'
呈现为:&lt; input type =“checkbox” ...&gt;
一个可调用的对象,接收CheckboxInput 的值并如果复选框应该勾上返回True。

  • 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;

  • RadioSelect 单选

template_name:'django/forms/widgets/radio.html'
option_template_name:'django/forms/widgets/radio_option.html'

  • 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>

  • CheckboxSelectMultiple 多选
  • FileInput 文件上传

template_name:'django/forms/widgets/file.html'
呈现为:&lt; input type =“file” ...&gt;

你可能感兴趣的:(django_form_widget速查)