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


Python forms.DurationField方法代码示例

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


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

示例1: get_internal_type

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import DurationField [as 别名]
def get_internal_type(self):
        return "DurationField" 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:4,代码来源:__init__.py

示例2: get_db_converters

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import DurationField [as 别名]
def get_db_converters(self, connection):
        converters = []
        if not connection.features.has_native_duration_field:
            converters.append(connection.ops.convert_durationfield_value)
        return converters + super(DurationField, self).get_db_converters(connection) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:7,代码来源:__init__.py

示例3: formfield

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import DurationField [as 别名]
def formfield(self, **kwargs):
        defaults = {
            'form_class': forms.DurationField,
        }
        defaults.update(kwargs)
        return super(DurationField, self).formfield(**defaults) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:8,代码来源:__init__.py

示例4: formfield

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import DurationField [as 别名]
def formfield(self, **kwargs):
        defaults = {
            'form_class': forms.DurationField,
        }
        defaults.update(kwargs)
        return super().formfield(**defaults) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:8,代码来源:__init__.py

示例5: formfield

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import DurationField [as 别名]
def formfield(self, **kwargs):
        return super().formfield(**{
            'form_class': forms.DurationField,
            **kwargs,
        }) 
开发者ID:PacktPublishing,项目名称:Hands-On-Application-Development-with-PyCharm,代码行数:7,代码来源:__init__.py

示例6: test_durationfield_clean

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import DurationField [as 别名]
def test_durationfield_clean(self):
        f = DurationField()
        self.assertEqual(datetime.timedelta(seconds=30), f.clean('30'))
        self.assertEqual(datetime.timedelta(minutes=15, seconds=30), f.clean('15:30'))
        self.assertEqual(datetime.timedelta(hours=1, minutes=15, seconds=30), f.clean('1:15:30'))
        self.assertEqual(
            datetime.timedelta(days=1, hours=1, minutes=15, seconds=30, milliseconds=300),
            f.clean('1 1:15:30.3')
        ) 
开发者ID:nesdis,项目名称:djongo,代码行数:11,代码来源:test_durationfield.py

示例7: test_overflow

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import DurationField [as 别名]
def test_overflow(self):
        msg = "The number of days must be between {min_days} and {max_days}.".format(
            min_days=datetime.timedelta.min.days,
            max_days=datetime.timedelta.max.days,
        )
        f = DurationField()
        with self.assertRaisesMessage(ValidationError, msg):
            f.clean('1000000000 00:00:00')
        with self.assertRaisesMessage(ValidationError, msg):
            f.clean('-1000000000 00:00:00') 
开发者ID:nesdis,项目名称:djongo,代码行数:12,代码来源:test_durationfield.py

示例8: test_overflow_translation

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import DurationField [as 别名]
def test_overflow_translation(self):
        msg = "Le nombre de jours doit être entre {min_days} et {max_days}.".format(
            min_days=datetime.timedelta.min.days,
            max_days=datetime.timedelta.max.days,
        )
        with translation.override('fr'):
            with self.assertRaisesMessage(ValidationError, msg):
                DurationField().clean('1000000000 00:00:00') 
开发者ID:nesdis,项目名称:djongo,代码行数:10,代码来源:test_durationfield.py

示例9: test_durationfield_render

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import DurationField [as 别名]
def test_durationfield_render(self):
        self.assertWidgetRendersTo(
            DurationField(initial=datetime.timedelta(hours=1)),
            '<input id="id_f" type="text" name="f" value="01:00:00" required>',
        ) 
开发者ID:nesdis,项目名称:djongo,代码行数:7,代码来源:test_durationfield.py

示例10: test_durationfield_integer_value

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import DurationField [as 别名]
def test_durationfield_integer_value(self):
        f = DurationField()
        self.assertEqual(datetime.timedelta(0, 10800), f.clean(10800)) 
开发者ID:nesdis,项目名称:djongo,代码行数:5,代码来源:test_durationfield.py

示例11: test_invalid_string

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import DurationField [as 别名]
def test_invalid_string(self):
        field = models.DurationField()
        with self.assertRaises(exceptions.ValidationError) as cm:
            field.clean('not a datetime', None)
        self.assertEqual(cm.exception.code, 'invalid')
        self.assertEqual(
            cm.exception.message % cm.exception.params,
            "'not a datetime' value has an invalid format. "
            "It must be in [DD] [HH:[MM:]]ss[.uuuuuu] format."
        ) 
开发者ID:nesdis,项目名称:djongo,代码行数:12,代码来源:test_durationfield.py

示例12: test_formfield

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import DurationField [as 别名]
def test_formfield(self):
        field = models.DurationField()
        self.assertIsInstance(field.formfield(), forms.DurationField) 
开发者ID:nesdis,项目名称:djongo,代码行数:5,代码来源:test_durationfield.py

示例13: test_durationfield_prepare_value

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import DurationField [as 别名]
def test_durationfield_prepare_value(self):
        field = DurationField()
        td = datetime.timedelta(minutes=15, seconds=30)
        self.assertEqual(field.prepare_value(td), duration_string(td))
        self.assertEqual(field.prepare_value('arbitrary'), 'arbitrary')
        self.assertIsNone(field.prepare_value(None)) 
开发者ID:nesdis,项目名称:djongo,代码行数:8,代码来源:test_durationfield.py


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