本文整理汇总了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
示例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
示例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
示例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
示例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