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


Python fields.DateTimeField方法代碼示例

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


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

示例1: test_regular_fields

# 需要導入模塊: from mongoengine import fields [as 別名]
# 或者: from mongoengine.fields import DateTimeField [as 別名]
def test_regular_fields(self):
        """
        Model fields should map to their equivelent serializer fields.
        """

        class TestSerializer(DocumentSerializer):
            class Meta:
                model = RegularModel
                fields = '__all__'

        regex_repr = "re.compile('^valid_regex')"

        expected = dedent("""
            TestSerializer():
                id = ObjectIdField(read_only=True)
                str_field = CharField(required=False)
                str_regex_field = RegexField(regex=%s, required=False)
                url_field = URLField(required=False)
                email_field = EmailField(required=False)
                int_field = IntegerField(required=False)
                long_field = IntegerField(required=False)
                float_field = FloatField(required=False)
                boolean_field = BooleanField(required=False)
                nullboolean_field = NullBooleanField(required=False)
                date_field = DateTimeField(required=False)
                complexdate_field = DateTimeField(required=False)
                uuid_field = UUIDField(required=False)
                id_field = ObjectIdField(required=False)
                decimal_field = DecimalField(decimal_places=2, max_digits=65536, required=False)
                custom_field = DocumentField(model_field=<tests.test_basic.CustomField: custom_field>, required=False)
        """ % regex_repr)

        assert repr(TestSerializer()) == expected 
開發者ID:umutbozkurt,項目名稱:django-rest-framework-mongoengine,代碼行數:35,代碼來源:test_basic.py

示例2: test_meta_exclude

# 需要導入模塊: from mongoengine import fields [as 別名]
# 或者: from mongoengine.fields import DateTimeField [as 別名]
def test_meta_exclude(self):
        """
        Serializer should respect Meta.exclude
        """

        class TestSerializer(DocumentSerializer):
            class Meta:
                model = RegularModel
                exclude = ('decimal_field', 'custom_field')

        regex_repr = "re.compile('^valid_regex')"

        expected = dedent("""
            TestSerializer():
                id = ObjectIdField(read_only=True)
                str_field = CharField(required=False)
                str_regex_field = RegexField(regex=%s, required=False)
                url_field = URLField(required=False)
                email_field = EmailField(required=False)
                int_field = IntegerField(required=False)
                long_field = IntegerField(required=False)
                float_field = FloatField(required=False)
                boolean_field = BooleanField(required=False)
                nullboolean_field = NullBooleanField(required=False)
                date_field = DateTimeField(required=False)
                complexdate_field = DateTimeField(required=False)
                uuid_field = UUIDField(required=False)
                id_field = ObjectIdField(required=False)
        """ % regex_repr)

        assert repr(TestSerializer()) == expected 
開發者ID:umutbozkurt,項目名稱:django-rest-framework-mongoengine,代碼行數:33,代碼來源:test_basic.py


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