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


Python widgets.TextInput方法代码示例

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


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

示例1: __init__

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import TextInput [as 别名]
def __init__(self, attrs=None):
        _widgets = (
            widgets.TextInput(
                attrs={'data-geo': 'formatted_address', 'data-id': 'map_place'}
            ),
            widgets.TextInput(
                attrs={
                    'data-geo': 'lat',
                    'data-id': 'map_latitude',
                    'placeholder': _('Latitude'),
                }
            ),
            widgets.TextInput(
                attrs={
                    'data-geo': 'lng',
                    'data-id': 'map_longitude',
                    'placeholder': _('Longitude'),
                }
            ),
        )
        super(PlacesWidget, self).__init__(_widgets, attrs) 
开发者ID:oscarmcm,项目名称:django-places,代码行数:23,代码来源:widgets.py

示例2: test_widgets_with_media

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import TextInput [as 别名]
def test_widgets_with_media(self):
        class WidgetWithMedia(TextInput):
            class Media:
                js = ['test.js']
                css = {'all': ['test.css']}

        class FormWithWidgetMedia(ClusterForm):
            class Meta:
                model = Restaurant
                fields = ['name', 'tags', 'serves_hot_dogs', 'proprietor']
                widgets = {
                    'name': WidgetWithMedia
                }

        form = FormWithWidgetMedia()

        self.assertIn('test.js', str(form.media['js']))
        self.assertIn('test.css', str(form.media['css'])) 
开发者ID:wagtail,项目名称:django-modelcluster,代码行数:20,代码来源:test_cluster_form.py

示例3: __init__

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import TextInput [as 别名]
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # 只修改widget
        self.fields['username'].widget = widgets.TextInput(
            attrs={
                'placeholder': 'Username',
                'class': 'form-control',
                'style': 'margin-bottom: 10px'
            })
        self.fields['email'].widget = widgets.EmailInput(
            attrs={
                'placeholder': 'Email',
                'class': 'form-control'
            })
        self.fields['password1'].widget = widgets.PasswordInput(
            attrs={
                'placeholder': 'New password',
                'class': 'form-control'
            })
        self.fields['password2'].widget = widgets.PasswordInput(
            attrs={
                'placeholder': 'Repeat password',
                'class': 'form-control'
            }) 
开发者ID:enjoy-binbin,项目名称:Django-blog,代码行数:27,代码来源:forms.py

示例4: test_edit_attachments_auto_device_name

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import TextInput [as 别名]
def test_edit_attachments_auto_device_name(self):
        volume = self.cinder_volumes.first()
        servers = [s for s in self.servers.list()
                   if s.tenant_id == self.request.user.tenant_id]
        volume.attachments = [{'id': volume.id,
                               'volume_id': volume.id,
                               'volume_name': volume.name,
                               'instance': servers[0],
                               'device': '',
                               'server_id': servers[0].id}]

        cinder.volume_get(IsA(http.HttpRequest), volume.id).AndReturn(volume)
        api.nova.server_list(IsA(http.HttpRequest)).AndReturn([servers, False])
        self.mox.ReplayAll()

        url = reverse('horizon:project:volumes:volumes:attach',
                      args=[volume.id])
        res = self.client.get(url)
        form = res.context['form']
        self.assertTrue(isinstance(form.fields['device'].widget,
                                   widgets.TextInput))
        self.assertFalse(form.fields['device'].required) 
开发者ID:CiscoSystems,项目名称:avos,代码行数:24,代码来源:tests.py

示例5: test_DictCharWidget_renders_with_empty_string_as_input_data

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import TextInput [as 别名]
def test_DictCharWidget_renders_with_empty_string_as_input_data(self):
        names = [factory.make_string(), factory.make_string()]
        initials = []
        labels = [factory.make_string(), factory.make_string()]
        widget = DictCharWidget(
            [widgets.TextInput, widgets.TextInput, widgets.CheckboxInput],
            names,
            initials,
            labels,
            skip_check=True,
        )
        name = factory.make_string()
        html_widget = fromstring(
            "<root>" + widget.render(name, "") + "</root>"
        )
        widget_names = XPath("fieldset/input/@name")(html_widget)
        widget_labels = XPath("fieldset/label/text()")(html_widget)
        expected_names = [
            "%s_%s" % (name, widget_name) for widget_name in names
        ]
        self.assertEqual(
            [expected_names, labels], [widget_names, widget_labels]
        ) 
开发者ID:maas,项目名称:maas,代码行数:25,代码来源:test_config_forms.py

示例6: test_DictCharWidget_renders_with_initial_when_no_value

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import TextInput [as 别名]
def test_DictCharWidget_renders_with_initial_when_no_value(self):
        """Widgets should use initial value if rendered without value."""
        names = [factory.make_name()]
        initials = [factory.make_name()]
        labels = [factory.make_name()]
        mock_widget = Mock()
        mock_widget.configure_mock(**{"render.return_value": ""})
        widget = DictCharWidget(
            [mock_widget, widgets.TextInput],
            names,
            initials,
            labels,
            skip_check=True,
        )
        widget.render("foo", [])

        self.assertThat(
            mock_widget.render, MockCalledOnceWith(ANY, initials[0], ANY)
        ) 
开发者ID:maas,项目名称:maas,代码行数:21,代码来源:test_config_forms.py

示例7: bootstrap_input_type

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import TextInput [as 别名]
def bootstrap_input_type(field):
    """
    Return input type to use for field
    """
    try:
        widget = field.field.widget
    except:
        raise ValueError("Expected a Field, got a %s" % type(field))
    input_type = getattr(widget, 'bootstrap_input_type', None)
    if input_type:
        return str(input_type)
    if isinstance(widget, TextInput):
        return u'text'
    if isinstance(widget, CheckboxInput):
        return u'checkbox'
    if isinstance(widget, CheckboxSelectMultiple):
        return u'multicheckbox'
    if isinstance(widget, RadioSelect):
        return u'radioset'
    return u'default' 
开发者ID:mediafactory,项目名称:yats,代码行数:22,代码来源:bootstrap_toolkit.py

示例8: __init__

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import TextInput [as 别名]
def __init__(self, *args, **kwargs):
            super(Code.ComponentForm, self).__init__(*args, **kwargs)
            self.fields['description'].widget = Textarea(attrs={'cols': 50, 'rows': 5})
            self.fields['max_size'].widget = TextInput(attrs={'style':'width:5em'})
            self.fields['allowed'].widget = SelectMultiple(choices=CODE_TYPES, attrs={'style':'width:40em', 'size': 15})
            self.initial['allowed'] = self._initial_allowed 
开发者ID:sfu-fas,项目名称:coursys,代码行数:8,代码来源:code.py

示例9: __init__

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import TextInput [as 别名]
def __init__(self, *args, **kwargs):
            super(Codefile.ComponentForm, self).__init__(*args, **kwargs)
            self.fields['description'].widget = Textarea(attrs={'cols': 50, 'rows': 5})
            self.fields['max_size'].widget = TextInput(attrs={'style':'width:5em'})
            del self.fields['specified_filename'] # our filename and filename.type do a better job 
开发者ID:sfu-fas,项目名称:coursys,代码行数:7,代码来源:codefile.py

示例10: as_text

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import TextInput [as 别名]
def as_text(self, attrs=None, **kwargs):
        """
        Returns a string of HTML for representing this as an <input type="text">.
        """
        return self.as_widget(TextInput(), attrs, **kwargs) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:7,代码来源:forms.py

示例11: as_text

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import TextInput [as 别名]
def as_text(self, attrs=None, **kwargs):
        """
        Return a string of HTML for representing this as an <input type="text">.
        """
        return self.as_widget(TextInput(), attrs, **kwargs) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:7,代码来源:boundfield.py

示例12: test_widgets_with_media_on_child_form

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import TextInput [as 别名]
def test_widgets_with_media_on_child_form(self):
        """
        The media property of ClusterForm should pick up media defined on child forms too
        """
        class FancyTextInput(TextInput):
            class Media:
                js = ['fancy-text-input.js']

        class FancyFileUploader(FileInput):
            class Media:
                js = ['fancy-file-uploader.js']

        class FormWithWidgetMedia(ClusterForm):
            class Meta:
                model = Gallery
                fields = ['title']
                widgets = {
                    'title': FancyTextInput,
                }

                formsets = {
                    'images': {
                        'fields': ['image'],
                        'widgets': {'image': FancyFileUploader}
                    }
                }

        form = FormWithWidgetMedia()

        self.assertIn('fancy-text-input.js', str(form.media['js']))
        self.assertIn('fancy-file-uploader.js', str(form.media['js'])) 
开发者ID:wagtail,项目名称:django-modelcluster,代码行数:33,代码来源:test_cluster_form.py

示例13: __init__

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import TextInput [as 别名]
def __init__(self, attrs=None):
        _widgets = (
            widgets.TextInput(),
            LabeledCheckboxInput(label="Include CommonName")
        )
        super(SubjectAltNameWidget, self).__init__(_widgets, attrs) 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:8,代码来源:widgets.py

示例14: textinfo

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import TextInput [as 别名]
def textinfo(cls, choice):
        attrs = {
            "placeholder": choice.get("extra_info_text"),
            "class": "extra-widget extra-widget-text",
            "style": "display: none;",
        }
        return Field(required=False, widget=TextInput(attrs=attrs)) 
开发者ID:project-callisto,项目名称:callisto-core,代码行数:9,代码来源:widgets.py

示例15: test_launch_form_instance_device_name_showed

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import TextInput [as 别名]
def test_launch_form_instance_device_name_showed(self):
        self._test_launch_form_instance_show_device_name(
            u'vda', widgets.TextInput, {
                'name': 'device_name', 'value': 'vda',
                'attrs': {'id': 'id_device_name'}}
        ) 
开发者ID:CiscoSystems,项目名称:avos,代码行数:8,代码来源:tests.py


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