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


Python widgets.NumberInput方法代码示例

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


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

示例1: __init__

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import NumberInput [as 别名]
def __init__(self, attrs=None, choices=(), default_unit=None):
        """
        Split the field in 2 widgets:
        - the first widget is a positive integer input,
        - the second widget is a select box to choose a pre-defined time unit (minutes, hours,
          days, weeks or months),

        e.g: 3 hours is split in: 3 (integer input) | hour (select)
        """
        self.default_unit = default_unit
        super().__init__(
            (
                widgets.NumberInput({**(attrs or {}), "min": 0}),
                widgets.Select(attrs, choices),
            )
        ) 
开发者ID:openfun,项目名称:richie,代码行数:18,代码来源:duration.py

示例2: __init__

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import NumberInput [as 别名]
def __init__(
        self,
        attrs=None,
        choices=(),
        default_effort_unit=None,
        default_reference_unit=None,
    ):
        """
        Split the field in 3 widgets:
        - the first widget is a positive integer input,
        - the second widget is a select box to choose a pre-defined time unit (minutes, hours,
          days, weeks or months),
        - the third widget is a select box to choose the pre-defined time unit of reference.

        e.g: 3 hours/day is split in: 3 (integer input) | hour (select) | day (select)
        """
        self.default_effort_unit = default_effort_unit
        self.default_reference_unit = default_reference_unit
        super().__init__(
            (
                widgets.NumberInput({**(attrs or {}), "min": 0}),
                # Remove the last choice: it can never be chosen as it must be strictly smaller
                # than the reference time unit
                widgets.Select(attrs, choices[:-1]),
                # Remove the first choice: it can never be chosen as it must be strictly greater
                # than the effort time unit
                widgets.Select(attrs, choices[1:]),
            )
        ) 
开发者ID:openfun,项目名称:richie,代码行数:31,代码来源:effort.py

示例3: test_attrs_not_localized

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import NumberInput [as 别名]
def test_attrs_not_localized(self):
        widget = NumberInput(attrs={'max': 12345, 'min': 1234, 'step': 9999})
        self.check_html(
            widget, 'name', 'value',
            '<input type="number" name="name" value="value" max="12345" min="1234" step="9999">'
        ) 
开发者ID:nesdis,项目名称:djongo,代码行数:8,代码来源:test_numberinput.py

示例4: __init__

# 需要导入模块: from django.forms import widgets [as 别名]
# 或者: from django.forms.widgets import NumberInput [as 别名]
def __init__(self, attrs=None):
        # create choices for days, months, years
        _attrs = attrs or {}  # default class
        _attrs['class'] = (_attrs.get('class', '') + ' w-month-year').strip()
        _widgets = [widgets.Select(attrs=_attrs, choices=MONTHS.items())]
        _attrs['class'] += " w-year"
        _widgets.append(widgets.NumberInput(attrs=_attrs))
        super(MonthSelectorWidget, self).__init__(_widgets, attrs) 
开发者ID:clearspark,项目名称:django-monthfield,代码行数:10,代码来源:widgets.py

示例5: __init__

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

        # No fancy widgets
        self.filters.get('court__jurisdiction').field.widget = TextInput()
        self.filters.get('court__level_of_appeal').field.widget = TextInput()
        self.filters.get('has_reference_to_law').field.widget = NumberInput() 
开发者ID:openlegaldata,项目名称:oldp,代码行数:9,代码来源:filters.py


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