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


Python models.CommaSeparatedIntegerField方法代碼示例

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


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

示例1: validate_field

# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import CommaSeparatedIntegerField [as 別名]
def validate_field(self, errors, opts, f):
            """
            MySQL has the following field length restriction:
            No character (varchar) fields can have a length exceeding 255
            characters if they have a unique index on them.
            """
            varchar_fields = (models.CharField,
                              models.CommaSeparatedIntegerField,
                              models.SlugField)
            if isinstance(f, varchar_fields) and f.max_length > 255 and f.unique:
                msg = ('"%(name)s": %(cls)s cannot have a "max_length" greater '
                       'than 255 when using "unique=True".')
                errors.add(opts, msg % {'name': f.name,
                                        'cls': f.__class__.__name__}) 
開發者ID:LuciferJack,項目名稱:python-mysql-pool,代碼行數:16,代碼來源:validation.py

示例2: validate_field

# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import CommaSeparatedIntegerField [as 別名]
def validate_field(self, errors, opts, f):
        """
        MySQL has the following field length restriction:
        No character (varchar) fields can have a length exceeding 255
        characters if they have a unique index on them.
        """
        from django.db import models
        varchar_fields = (models.CharField, models.CommaSeparatedIntegerField,
                models.SlugField)
        if (isinstance(f, varchar_fields) and f.unique
                and (f.max_length is None or int(f.max_length) > 255)):
            msg = '"%(name)s": %(cls)s cannot have a "max_length" greater than 255 when using "unique=True".'
            errors.add(opts, msg % {'name': f.name, 'cls': f.__class__.__name__}) 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:15,代碼來源:validation.py

示例3: test_csi_field

# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import CommaSeparatedIntegerField [as 別名]
def test_csi_field(self):
        field = models.CommaSeparatedIntegerField(max_length=100)
        name, path, args, kwargs = field.deconstruct()
        self.assertEqual(path, "django.db.models.CommaSeparatedIntegerField")
        self.assertEqual(args, [])
        self.assertEqual(kwargs, {"max_length": 100}) 
開發者ID:denisenkom,項目名稱:django-sqlserver,代碼行數:8,代碼來源:tests.py

示例4: test_CommaSeparatedIntegerField_deprecated

# 需要導入模塊: from django.db import models [as 別名]
# 或者: from django.db.models import CommaSeparatedIntegerField [as 別名]
def test_CommaSeparatedIntegerField_deprecated(self):
        class CommaSeparatedIntegerModel(models.Model):
            csi = models.CommaSeparatedIntegerField(max_length=64)

        model = CommaSeparatedIntegerModel()
        self.assertEqual(
            model.check(),
            [checks.Error(
                'CommaSeparatedIntegerField is removed except for support in '
                'historical migrations.',
                hint='Use CharField(validators=[validate_comma_separated_integer_list]) instead.',
                obj=CommaSeparatedIntegerModel._meta.get_field('csi'),
                id='fields.E901',
            )],
        ) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:17,代碼來源:test_deprecated_fields.py


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