當前位置: 首頁>>代碼示例>>Python>>正文


Python formats.localize_input方法代碼示例

本文整理匯總了Python中django.utils.formats.localize_input方法的典型用法代碼示例。如果您正苦於以下問題:Python formats.localize_input方法的具體用法?Python formats.localize_input怎麽用?Python formats.localize_input使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.utils.formats的用法示例。


在下文中一共展示了formats.localize_input方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _format_value

# 需要導入模塊: from django.utils import formats [as 別名]
# 或者: from django.utils.formats import localize_input [as 別名]
def _format_value(self, value):
        if self.is_localized:
            return formats.localize_input(value)
        return value 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:6,代碼來源:widgets.py

示例2: format_value

# 需要導入模塊: from django.utils import formats [as 別名]
# 或者: from django.utils.formats import localize_input [as 別名]
def format_value(self, value):
        """
        Return a value as it should appear when rendered in a template.
        """
        if value == '' or value is None:
            return None
        if self.is_localized:
            return formats.localize_input(value)
        return str(value) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:11,代碼來源:widgets.py

示例3: format_value

# 需要導入模塊: from django.utils import formats [as 別名]
# 或者: from django.utils.formats import localize_input [as 別名]
def format_value(self, value):
        """
        Return a value as it should appear when rendered in a template.
        """
        if value == '' or value is None:
            return None
        if self.is_localized:
            return formats.localize_input(value)
        return force_text(value) 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:11,代碼來源:widgets.py

示例4: format_value

# 需要導入模塊: from django.utils import formats [as 別名]
# 或者: from django.utils.formats import localize_input [as 別名]
def format_value(self, value):
        """
        Return a value as it should appear when rendered in a template.

        Missing method of django.forms.widgets.Widget class
        """
        if value == '' or value is None:
            return None
        return formats.localize_input(value, self.format) 
開發者ID:monim67,項目名稱:django-bootstrap-datepicker-plus,代碼行數:11,代碼來源:_compatibility.py

示例5: _has_changed

# 需要導入模塊: from django.utils import formats [as 別名]
# 或者: from django.utils.formats import localize_input [as 別名]
def _has_changed(self, initial, data):
        # If our field has show_hidden_initial=True, initial will be a string
        # formatted by HiddenInput using formats.localize_input, which is not
        # necessarily the format used for this widget. Attempt to convert it.
        try:
            input_format = formats.get_format('DATE_INPUT_FORMATS')[0]
            initial = datetime.datetime.strptime(initial, input_format).date()
        except (TypeError, ValueError):
            pass
        return super(DateInput, self)._has_changed(self._format_value(initial), data) 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:12,代碼來源:widgets.py

示例6: format_value

# 需要導入模塊: from django.utils import formats [as 別名]
# 或者: from django.utils.formats import localize_input [as 別名]
def format_value(self, value):
        if self.format and \
                isinstance(self.format, Promise):
            return formats.localize_input(value, force_text(self.format))
        else:
            return super().format_value(value=value) 
開發者ID:iguana-project,項目名稱:iguana,代碼行數:8,代碼來源:widgets.py

示例7: to_representation

# 需要導入模塊: from django.utils import formats [as 別名]
# 或者: from django.utils.formats import localize_input [as 別名]
def to_representation(self, value):
        coerce_to_string = getattr(self, 'coerce_to_string', api_settings.COERCE_DECIMAL_TO_STRING)

        if not isinstance(value, decimal.Decimal):
            value = decimal.Decimal(six.text_type(value).strip())

        quantized = self.quantize(value)

        if not coerce_to_string:
            return quantized
        if self.localize:
            return localize_input(quantized)

        return '{0:f}'.format(quantized) 
開發者ID:BeanWei,項目名稱:Dailyfresh-B2C,代碼行數:16,代碼來源:fields.py

示例8: test_floatfield_changed

# 需要導入模塊: from django.utils import formats [as 別名]
# 或者: from django.utils.formats import localize_input [as 別名]
def test_floatfield_changed(self):
        f = FloatField()
        n = 4.35
        self.assertFalse(f.has_changed(n, '4.3500'))

        with translation.override('fr'), self.settings(USE_L10N=True):
            f = FloatField(localize=True)
            localized_n = formats.localize_input(n)  # -> '4,35' in French
            self.assertFalse(f.has_changed(n, localized_n)) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:11,代碼來源:test_floatfield.py

示例9: test_decimalfield_changed

# 需要導入模塊: from django.utils import formats [as 別名]
# 或者: from django.utils.formats import localize_input [as 別名]
def test_decimalfield_changed(self):
        f = DecimalField(max_digits=2, decimal_places=2)
        d = decimal.Decimal("0.1")
        self.assertFalse(f.has_changed(d, '0.10'))
        self.assertTrue(f.has_changed(d, '0.101'))

        with translation.override('fr'), self.settings(USE_L10N=True):
            f = DecimalField(max_digits=2, decimal_places=2, localize=True)
            localized_d = formats.localize_input(d)  # -> '0,1' in French
            self.assertFalse(f.has_changed(d, localized_d)) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:12,代碼來源:test_decimalfield.py

示例10: format_value

# 需要導入模塊: from django.utils import formats [as 別名]
# 或者: from django.utils.formats import localize_input [as 別名]
def format_value(self, value):
        """
        返回在模板中呈現時應該出現的值。
        """
        if value == '' or value is None:
            return None
        if self.is_localized:
            return formats.localize_input(value)
        return str(value) 
開發者ID:newpanjing,項目名稱:simpleui,代碼行數:11,代碼來源:widgets.py


注:本文中的django.utils.formats.localize_input方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。