Python django.db.models 模块,BigIntegerField() 实例源码

我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用django.db.models.BigIntegerField()

项目:itunes    作者:kaminem64    | 项目源码 | 文件源码
def __unicode__(self):
        return self.id

# class ToCrawl(models.Model):
#     store_app_id = models.BigIntegerField(default=0)
#     name = models.CharField(max_length=200, default='-')
#     rank_type = models.CharField(max_length=20)
#     rank = models.IntegerField(blank=True, null=True)
#     date = models.DateTimeField()
#
#     is_crawled = models.BooleanField(default=False)
#     def __unicode__(self):
#         return self.id
项目:graphene-django    作者:graphql-python    | 项目源码 | 文件源码
def test_should_big_integer_convert_int():
    assert_conversion(models.BigIntegerField, graphene.Int)
项目:omni-forms    作者:omni-digital    | 项目源码 | 文件源码
def test_get_concrete_class_for_model_field(self):
        """
        The get_concrete_class_for_model_field method should return the correct OmniField subclass
        """
        self.assertEqual(OmniField.get_concrete_class_for_model_field(models.CharField()), OmniCharField)
        self.assertEqual(OmniField.get_concrete_class_for_model_field(models.NullBooleanField()), OmniBooleanField)
        self.assertEqual(OmniField.get_concrete_class_for_model_field(models.BooleanField()), OmniBooleanField)
        self.assertEqual(OmniField.get_concrete_class_for_model_field(models.DateTimeField()), OmniDateTimeField)
        self.assertEqual(OmniField.get_concrete_class_for_model_field(models.DecimalField()), OmniDecimalField)
        self.assertEqual(OmniField.get_concrete_class_for_model_field(models.EmailField()), OmniEmailField)
        self.assertEqual(OmniField.get_concrete_class_for_model_field(models.FloatField()), OmniFloatField)
        self.assertEqual(OmniField.get_concrete_class_for_model_field(models.IntegerField()), OmniIntegerField)
        self.assertEqual(OmniField.get_concrete_class_for_model_field(models.BigIntegerField()), OmniIntegerField)
        self.assertEqual(OmniField.get_concrete_class_for_model_field(models.PositiveIntegerField()), OmniIntegerField)
        self.assertEqual(OmniField.get_concrete_class_for_model_field(models.SmallIntegerField()), OmniIntegerField)
        self.assertEqual(OmniField.get_concrete_class_for_model_field(models.TimeField()), OmniTimeField)
        self.assertEqual(OmniField.get_concrete_class_for_model_field(models.URLField()), OmniUrlField)
        self.assertEqual(OmniField.get_concrete_class_for_model_field(models.SlugField()), OmniSlugField)
        self.assertEqual(OmniField.get_concrete_class_for_model_field(models.FileField()), OmniFileField)
        self.assertEqual(OmniField.get_concrete_class_for_model_field(models.ImageField()), OmniImageField)
        self.assertEqual(OmniField.get_concrete_class_for_model_field(models.DurationField()), OmniDurationField)
        self.assertEqual(
            OmniField.get_concrete_class_for_model_field(models.GenericIPAddressField()),
            OmniGenericIPAddressField
        )
        self.assertEqual(
            OmniField.get_concrete_class_for_model_field(models.CommaSeparatedIntegerField()),
            OmniCharField
        )
        self.assertEqual(
            OmniField.get_concrete_class_for_model_field(models.PositiveSmallIntegerField()),
            OmniIntegerField
        )
        self.assertEqual(
            OmniField.get_concrete_class_for_model_field(models.ForeignKey(DummyModel2)),
            OmniForeignKeyField
        )
        self.assertEqual(
            OmniField.get_concrete_class_for_model_field(models.ManyToManyField(DummyModel2)),
            OmniManyToManyField
        )
项目:omni-forms    作者:omni-digital    | 项目源码 | 文件源码
def get_concrete_class_for_model_field(cls, model_field):
        """
        Method for getting a concrete model class to represent the type of form field required

        :param model_field: Model Field instance
        :return: OmniField subclass
        """
        field_mapping = {
            models.CharField: OmniCharField,
            models.TextField: OmniCharField,
            models.BooleanField: OmniBooleanField,
            models.NullBooleanField: OmniBooleanField,
            models.DateField: OmniDateField,
            models.DateTimeField: OmniDateTimeField,
            models.DecimalField: OmniDecimalField,
            models.EmailField: OmniEmailField,
            models.FloatField: OmniFloatField,
            models.IntegerField: OmniIntegerField,
            models.BigIntegerField: OmniIntegerField,
            models.PositiveIntegerField: OmniIntegerField,
            models.PositiveSmallIntegerField: OmniIntegerField,
            models.SmallIntegerField: OmniIntegerField,
            models.CommaSeparatedIntegerField: OmniCharField,
            models.TimeField: OmniTimeField,
            models.URLField: OmniUrlField,
            models.ForeignKey: OmniForeignKeyField,
            models.ManyToManyField: OmniManyToManyField,
            models.SlugField: OmniSlugField,
            models.FileField: OmniFileField,
            models.ImageField: OmniImageField,
            models.DurationField: OmniDurationField,
            models.GenericIPAddressField: OmniGenericIPAddressField
        }
        field_mapping.update(cls.get_custom_field_mapping())
        return field_mapping.get(model_field.__class__)
项目:django-pgMemento    作者:onebit0fme    | 项目源码 | 文件源码
def add_audit_id(sender, **kwargs):
    try:
        sender._meta.get_field('audit_id')
    except FieldDoesNotExist:
        field = models.BigIntegerField(null=True, blank=True)
        field.contribute_to_class(sender, 'audit_id')
项目:mes    作者:osess    | 项目源码 | 文件源码
def has_int_pk(model):
    """Tests whether the given model has an integer primary key."""
    pk = model._meta.pk
    return (
        (
            isinstance(pk, (models.IntegerField, models.AutoField)) and
            not isinstance(pk, models.BigIntegerField)
        ) or (
            isinstance(pk, models.ForeignKey) and has_int_pk(pk.rel.to)
        )
    )
项目:Sentry    作者:NetEaseGame    | 项目源码 | 文件源码
def get_internal_type(self):
            return "BigIntegerField"
项目:Sentry    作者:NetEaseGame    | 项目源码 | 文件源码
def get_internal_type(self):
            return "BigIntegerField"
项目:itunes    作者:kaminem64    | 项目源码 | 文件源码
def __unicode__(self):
        return self.id


#--------------------------------------------------------#
# class Ranking(models.Model):
#     app = models.ForeignKey(App) #category is included in app
#     type = models.CharField(max_length=20) #free, paid, grossing
#     rank = models.IntegerField(blank=True, null=True)
#     date = models.DateTimeField()
#
#     crawled_on = models.DateTimeField(auto_now_add=True)
#
#     def __unicode__(self):
#         return self.id

# class Rating(models.Model):
#     app = models.ForeignKey(App)
#     date = models.DateTimeField()
#     five_stars = models.BigIntegerField(default=0)
#     four_stars = models.BigIntegerField(default=0)
#     three_stars = models.BigIntegerField(default=0)
#     two_stars = models.BigIntegerField(default=0)
#     one_stars = models.BigIntegerField(default=0)
#
#     crawled_on = models.DateTimeField(auto_now_add=True)
#
#     def __unicode__(self):
#         return self.id

# class User(models.Model):
#     username = models.CharField(max_length=200)
#     user_apple_id = models.BigIntegerField(default=0)
#     user_reviews_url = models.URLField(blank=True, null=True)
#     # We could use an M2M structure to connect reviews to users;
#     # but for the sake of simplicity we didn't use it.
#     def __unicode__(self):
#         return self.id

# class Review(models.Model):
#     app = models.ForeignKey(App)
#     appfigures_id = models.IntegerField(blank=True, null=True)
#     user = models.ForeignKey(User)
#     review_id = models.BigIntegerField(default=0)
#     title = models.CharField(max_length=400)
#     body = models.TextField(blank=True, null=True)
#     star_rating = models.IntegerField(default=0)
#     date = models.DateTimeField()
#
#     crawled_on = models.DateTimeField(auto_now_add=True)
#     def __unicode__(self):
#         return self.id
项目:django_postgres_extensions    作者:primal100    | 项目源码 | 文件源码
def __init__(self, to_model, base_field=None, size=None, related_name=None, symmetrical=None,
                 related_query_name=None, limit_choices_to=None, to_field=None, db_constraint=False, **kwargs):

        try:
            to = to_model._meta.model_name
        except AttributeError:
            assert isinstance(to_model, six.string_types), (
                "%s(%r) is invalid. First parameter to ForeignKey must be "
                "either a model, a model name, or the string %r" % (
                    self.__class__.__name__, to_model,
                    RECURSIVE_RELATIONSHIP_CONSTANT,
                )
            )
            to = str(to_model)
        else:
            # For backwards compatibility purposes, we need to *try* and set
            # the to_field during FK construction. It won't be guaranteed to
            # be correct until contribute_to_class is called. Refs #12190.
            to_field = to_field or (to_model._meta.pk and to_model._meta.pk.name)
            if not base_field:
                field = to_model._meta.get_field(to_field)
                if not field.is_relation:
                    base_field_type = type(field)
                    internal_type = field.get_internal_type()
                    if internal_type == 'AutoField':
                        pass
                    elif internal_type == 'BigAutoField':
                        base_field = models.BigIntegerField()
                    elif hasattr(field, 'max_length'):
                        base_field = base_field_type(max_length = field.max_length)
                    else:
                        base_field = base_field_type()

        if not base_field:
            base_field = models.IntegerField()

        if symmetrical is None:
            symmetrical = (to == RECURSIVE_RELATIONSHIP_CONSTANT)

        kwargs['rel'] = self.rel_class(
            self, to, to_field,
            related_name=related_name,
            related_query_name=related_query_name,
            limit_choices_to=limit_choices_to,
            symmetrical=symmetrical,
        )
        self.has_null_arg = 'null' in kwargs

        self.db_constraint = db_constraint

        self.to = to

        if 'default' not in kwargs.keys():
            kwargs['default'] = []
        kwargs['blank'] = True

        self.from_fields = ['self']
        self.to_fields = [to_field]

        super(ArrayManyToManyField, self).__init__(base_field, size=size, **kwargs)