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