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


Python fields.BigIntegerField类代码示例

本文整理汇总了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
开发者ID:johnboiles,项目名称:django-bitfield,代码行数:30,代码来源:models.py

示例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)
开发者ID:callowayproject,项目名称:django-bitfield,代码行数:9,代码来源:models.py

示例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
开发者ID:tyrchen,项目名称:django-bitfield,代码行数:14,代码来源:models.py

示例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)
开发者ID:nessita,项目名称:django-bitfield,代码行数:7,代码来源:models.py

示例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)
开发者ID:johnboiles,项目名称:django-bitfield,代码行数:8,代码来源:models.py

示例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
开发者ID:NGFieldScope,项目名称:django-bitfield,代码行数:20,代码来源:models.py

示例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)
开发者ID:bourivouh,项目名称:django-countries-field,代码行数:11,代码来源:models.py

示例8: contribute_to_class

 def contribute_to_class(self, cls, name):
     BigIntegerField.contribute_to_class(self, cls, name)
     setattr(cls, self.name, BitFieldCreator(self))
开发者ID:johnboiles,项目名称:django-bitfield,代码行数:3,代码来源:models.py

示例9: __init__

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

示例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
开发者ID:vertisfinance,项目名称:django-timetravel-pg,代码行数:16,代码来源:models.py

示例11: __init__

 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,代码行数:5,代码来源:__init__.py


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