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