当前位置: 首页>>代码示例>>Python>>正文


Python widgets.Input方法代码示例

本文整理汇总了Python中django.forms.widgets.Input方法的典型用法代码示例。如果您正苦于以下问题:Python widgets.Input方法的具体用法?Python widgets.Input怎么用?Python widgets.Input使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.forms.widgets的用法示例。


在下文中一共展示了widgets.Input方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: render_layout

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import Input [as 别名]
def render_layout(self, form, context, template_pack=TEMPLATE_PACK):
        """
        Copy any field label to the ``placeholder`` attribute.
        Note, this method is called when :attr:`layout` is defined.
        """
        # Writing the label values into the field placeholders.
        # This is done at rendering time, so the Form.__init__() could update any labels before.
        # Django 1.11 no longer lets EmailInput or URLInput inherit from TextInput,
        # so checking for `Input` instead while excluding `HiddenInput`.
        for field in form.fields.values():
            if field.label and \
                    isinstance(field.widget, (Input, forms.Textarea)) and \
                    not isinstance(field.widget, forms.HiddenInput):
                field.widget.attrs['placeholder'] = u"{0}:".format(field.label)

        return super(CompactLabelsCommentFormHelper, self).render_layout(form, context, template_pack=template_pack) 
开发者ID:82Flex,项目名称:DCRM,代码行数:18,代码来源:helper.py

示例2: __init__

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import Input [as 别名]
def __init__(self, *args, **kwargs):
        super(BootsrapForm, self).__init__(*args, **kwargs)
        for field in self.fields.values():
            # Only tweak the field if it will be displayed
            if not isinstance(field.widget, widgets.HiddenInput):
                attrs = {}
                if (
                    isinstance(field.widget, (widgets.Input, widgets.Select, widgets.Textarea)) and
                    not isinstance(field.widget, (widgets.CheckboxInput,))
                ):
                    attrs['class'] = "form-control"
                if isinstance(field.widget, (widgets.Input, widgets.Textarea)) and field.label:
                    attrs["placeholder"] = field.label
                if field.required:
                    attrs["required"] = "required"
                field.widget.attrs.update(attrs) 
开发者ID:nitmir,项目名称:django-cas-server,代码行数:18,代码来源:forms.py

示例3: test_no_trailing_newline_in_attrs

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import Input [as 别名]
def test_no_trailing_newline_in_attrs(self):
        self.check_html(Input(), 'name', 'value', strict=True, html='<input type="None" name="name" value="value">') 
开发者ID:nesdis,项目名称:djongo,代码行数:4,代码来源:test_widget.py

示例4: test_attr_false_not_rendered

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import Input [as 别名]
def test_attr_false_not_rendered(self):
        html = '<input type="None" name="name" value="value">'
        self.check_html(Input(), 'name', 'value', html=html, attrs={'readonly': False}) 
开发者ID:nesdis,项目名称:djongo,代码行数:5,代码来源:test_widget.py

示例5: test_attrs_with_type

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import Input [as 别名]
def test_attrs_with_type(self):
        attrs = {'type': 'date'}
        widget = Input(attrs)
        self.check_html(widget, 'name', 'value', '<input type="date" name="name" value="value">')
        # reuse the same attrs for another widget
        self.check_html(Input(attrs), 'name', 'value', '<input type="date" name="name" value="value">')
        attrs['type'] = 'number'  # shouldn't change the widget type
        self.check_html(widget, 'name', 'value', '<input type="date" name="name" value="value">') 
开发者ID:nesdis,项目名称:djongo,代码行数:10,代码来源:test_input.py

示例6: test_custom_widget_kwarg

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import Input [as 别名]
def test_custom_widget_kwarg(self):
        """The widget can be overridden with a kwarg."""
        field = forms.JSONField(widget=widgets.Input)
        self.assertIsInstance(field.widget, widgets.Input) 
开发者ID:nesdis,项目名称:djongo,代码行数:6,代码来源:test_json.py

示例7: test_custom_widget_attribute

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import Input [as 别名]
def test_custom_widget_attribute(self):
        """The widget can be overridden with an attribute."""
        class CustomJSONField(forms.JSONField):
            widget = widgets.Input

        field = CustomJSONField()
        self.assertIsInstance(field.widget, widgets.Input) 
开发者ID:nesdis,项目名称:djongo,代码行数:9,代码来源:test_json.py


注:本文中的django.forms.widgets.Input方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。