本文整理汇总了Python中django.db.models.fields.BigIntegerField类的典型用法代码示例。如果您正苦于以下问题:Python BigIntegerField类的具体用法?Python BigIntegerField怎么用?Python BigIntegerField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BigIntegerField类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
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: get_db_prep_lookup
def get_db_prep_lookup(self, lookup_type, value, connection=None, prepared=False):
if isinstance(value, SQLEvaluator) and isinstance(value.expression, Bit):
value = value.expression
if isinstance(value, (BitHandler, Bit)):
return BitQueryLookupWrapper(self.model._meta.db_table, self.name, value)
if connection is None:
return BigIntegerField.get_db_prep_lookup(self, lookup_type=lookup_type, value=value)
return BigIntegerField.get_db_prep_lookup(self, lookup_type=lookup_type, value=value,
connection=connection, prepared=prepared)
示例3: __init__
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
示例4: get_db_prep_lookup
def get_db_prep_lookup(self, lookup_type, value, connection, prepared=False):
if isinstance(value, SQLEvaluator) and isinstance(value.expression, Bit):
value = value.expression
if isinstance(value, (BitHandler, Bit)):
return [value.mask]
return BigIntegerField.get_db_prep_lookup(self, lookup_type=lookup_type, value=value,
connection=connection, prepared=prepared)
示例5: get_prep_lookup
def get_prep_lookup(self, lookup_type, value):
if isinstance(value, SQLEvaluator) and isinstance(value.expression, Bit):
value = value.expression
if isinstance(value, Bit):
if lookup_type in ('exact',):
return value
raise TypeError('Lookup type %r not supported with `Bit` type.' % lookup_type)
return BigIntegerField.get_prep_lookup(self, lookup_type, value)
示例6: __init__
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
示例7: get_db_prep_lookup
def get_db_prep_lookup(self, lookup_type, value, connection, prepared=False):
if isinstance(getattr(value, 'expression', None), Bit):
value = value.expression
if isinstance(value, (BitHandler, Bit)):
if hasattr(self, 'class_lookups'):
# Django 1.7+
return [value.mask]
else:
return BitQueryLookupWrapper(self.model._meta.db_table, self.db_column or self.name, value)
return BigIntegerField.get_db_prep_lookup(self, lookup_type=lookup_type, value=value,
connection=connection, prepared=prepared)
示例8: contribute_to_class
def contribute_to_class(self, cls, name):
BigIntegerField.contribute_to_class(self, cls, name)
setattr(cls, self.name, BitFieldCreator(self))
示例9: __init__
def __init__(self, flags, *args, **kwargs):
BigIntegerField.__init__(self, *args, **kwargs)
self.flags = flags
示例10: auto_to_integer
def auto_to_integer(field):
_field = BigIntegerField()
_field.name = field.attname
_field.db_index = field.db_index
_field.verbose_name = field.verbose_name
_field.db_column = field.db_column
_field.db_tablespace = field.db_tablespace
_field.primary_key = field.primary_key
_field.serialize = field.serialize
_field.null = field.null
_field._unique = field._unique
_field.unique_for_date = field.unique_for_date
_field.unique_for_month = field.unique_for_month
_field.unique_for_year = field.unique_for_year
return _field
示例11: __init__
def __init__(self, flags, *args, **kwargs):
kwargs['choices']= enumerate(x for x in flags)
BigIntegerField.__init__(self, *args, **kwargs)
self.flags = flags