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


Python BigIntegerField.__init__方法代码示例

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


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

示例1: __init__

# 需要导入模块: from django.db.models.fields import BigIntegerField [as 别名]
# 或者: from django.db.models.fields.BigIntegerField import __init__ [as 别名]
    def __init__(self, flags, default=None, *args, **kwargs):
        if isinstance(flags, dict):
            # Get only integer keys in correct range
            valid_keys = (k for k in flags.keys() if isinstance(k, int) and (0 <= k < MAX_FLAG_COUNT))
            if not valid_keys:
                raise ValueError('Wrong keys or empty dictionary')
            # Fill list with values from dict or with empty values
            flags = [flags.get(i, '') for i in range(max(valid_keys) + 1)]

        if len(flags) > MAX_FLAG_COUNT:
            raise ValueError('Too many flags')

        flags = list(flags)
        labels = []
        for num, flag in enumerate(flags):
            if isinstance(flag, (tuple, list)):
                flags[num] = flag[0]
                labels.append(flag[1])
            else:
                labels.append(flag)

        if isinstance(default, (list, tuple, set, frozenset)):
            new_value = 0
            for flag in default:
                new_value |= Bit(flags.index(flag))
            default = new_value

        BigIntegerField.__init__(self, default=default, *args, **kwargs)
        self.flags = flags
        self.labels = labels
开发者ID:johnboiles,项目名称:django-bitfield,代码行数:32,代码来源:models.py

示例2: __init__

# 需要导入模块: from django.db.models.fields import BigIntegerField [as 别名]
# 或者: from django.db.models.fields.BigIntegerField import __init__ [as 别名]
    def __init__(self, flags, *args, **kwargs):
        if isinstance(flags, dict):
            # Get only integer keys in correct range
            valid_keys = (k for k in flags.keys() if isinstance(k, int) and (0 <= k < MAX_FLAG_COUNT))
            if not valid_keys:
                raise ValueError('Wrong keys or empty dictionary')
            # Fill list with values from dict or with empty values
            flags = [flags.get(i, '') for i in range(max(valid_keys) + 1)]

        if len(flags) > MAX_FLAG_COUNT:
            raise ValueError('Too many flags')

        BigIntegerField.__init__(self, *args, **kwargs)
        self.flags = flags
开发者ID:tyrchen,项目名称:django-bitfield,代码行数:16,代码来源:models.py

示例3: __init__

# 需要导入模块: from django.db.models.fields import BigIntegerField [as 别名]
# 或者: from django.db.models.fields.BigIntegerField import __init__ [as 别名]
    def __init__(self, flags, default=None, *args, **kwargs):
        if isinstance(flags, dict):
            # Get only integer keys in correct range
            valid_keys = (k for k in flags.keys() if isinstance(k, int) and (0 <= k < MAX_FLAG_COUNT))
            if not valid_keys:
                raise ValueError("Wrong keys or empty dictionary")
            # Fill list with values from dict or with empty values
            flags = [flags.get(i, "") for i in range(max(valid_keys) + 1)]

        if len(flags) > MAX_FLAG_COUNT:
            raise ValueError("Too many flags")

        if isinstance(default, (list, tuple, set, frozenset)):
            new_value = 0
            for flag in default:
                new_value |= Bit(flags.index(flag))
            default = new_value

        BigIntegerField.__init__(self, default=default, *args, **kwargs)
        self.flags = flags
开发者ID:NGFieldScope,项目名称:django-bitfield,代码行数:22,代码来源:models.py

示例4: __init__

# 需要导入模块: from django.db.models.fields import BigIntegerField [as 别名]
# 或者: from django.db.models.fields.BigIntegerField import __init__ [as 别名]
 def __init__(self, flags, *args, **kwargs):
     BigIntegerField.__init__(self, *args, **kwargs)
     self.flags = flags
开发者ID:spulec,项目名称:django-bitfield,代码行数:5,代码来源:models.py

示例5: __init__

# 需要导入模块: from django.db.models.fields import BigIntegerField [as 别名]
# 或者: from django.db.models.fields.BigIntegerField import __init__ [as 别名]
 def __init__(self, flags,  *args, **kwargs):
     kwargs['choices']= enumerate(x for x in flags)
     
     BigIntegerField.__init__(self, *args, **kwargs)
     self.flags = flags
开发者ID:limnick,项目名称:django-bitfield,代码行数:7,代码来源:__init__.py


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