當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。