当前位置: 首页>>代码示例>>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;未经允许,请勿转载。