Python django.db.models.BigIntegerField() Examples

The following are 15 code examples for showing how to use django.db.models.BigIntegerField(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module django.db.models , or try the search function .

Example 1
Project: djongo   Author: nesdis   File: test_ordinary_fields.py    License: GNU Affero General Public License v3.0 6 votes vote down vote up
def test_max_length_warning(self):
        class Model(models.Model):
            integer = models.IntegerField(max_length=2)
            biginteger = models.BigIntegerField(max_length=2)
            smallinteger = models.SmallIntegerField(max_length=2)
            positiveinteger = models.PositiveIntegerField(max_length=2)
            positivesmallinteger = models.PositiveSmallIntegerField(max_length=2)

        for field in Model._meta.get_fields():
            if field.auto_created:
                continue
            with self.subTest(name=field.name):
                self.assertEqual(field.check(), [
                    DjangoWarning(
                        "'max_length' is ignored when used with %s." % field.__class__.__name__,
                        hint="Remove 'max_length' from field",
                        obj=field,
                        id='fields.W122',
                    )
                ]) 
Example 2
Project: django-twitter-stream   Author: michaelbrooks   File: fields.py    License: MIT License 5 votes vote down vote up
def formfield(self, **kwargs):
        defaults = {'min_value': 0,
                    'max_value': models.BigIntegerField.MAX_BIGINT * 2 - 1}
        defaults.update(kwargs)
        return super(PositiveBigIntegerField, self).formfield(**defaults) 
Example 3
Project: vortessence   Author: vortessence   File: models.py    License: GNU General Public License v2.0 5 votes vote down vote up
def db_type(self, connection):
        if 'mysql' in connection.__class__.__module__:
            return 'bigint UNSIGNED'
        return super(BigIntegerField, self).db_type(connection) 
Example 4
Project: vortessence   Author: vortessence   File: models.py    License: GNU General Public License v2.0 5 votes vote down vote up
def formfield(self, **kwargs):
        defaults = {'min_value': 0,
                    'max_value': BigIntegerField.MAX_BIGINT * 2 - 1}
        defaults.update(kwargs)
        return super(PositiveBigIntegerField, self).formfield(**defaults) 
Example 5
Project: vortessence   Author: vortessence   File: models.py    License: GNU General Public License v2.0 5 votes vote down vote up
def db_type(self, connection):
        if 'mysql' in connection.__class__.__module__:
            return 'bigint UNSIGNED'
        return super(BigIntegerField, self).db_type(connection) 
Example 6
Project: vortessence   Author: vortessence   File: models.py    License: GNU General Public License v2.0 5 votes vote down vote up
def formfield(self, **kwargs):
        defaults = {'min_value': 0,
                    'max_value': BigIntegerField.MAX_BIGINT * 2 - 1}
        defaults.update(kwargs)
        return super(PositiveBigIntegerField, self).formfield(**defaults) 
Example 7
Project: graphene-django   Author: graphql-python   File: test_converter.py    License: MIT License 5 votes vote down vote up
def test_should_big_integer_convert_int():
    assert_conversion(models.BigIntegerField, graphene.Int) 
Example 8
Project: FFXIVBOT   Author: Bluefissure   File: models.py    License: GNU General Public License v3.0 5 votes vote down vote up
def get_info(self):
        return "HuntLog#{}: {}-{} {}".format(
            self.id, self.server, self.monster, self.log_type
        )


## class TelegramChannel(models.Model):
##     name = models.CharField(default="", max_length=64)
##     group = models.ManyToManyField(QQGroup, null=True, blank=True, related_name="tele_channel")
##     last_push_time = models.BigIntegerField(default=0)
##
##     def __str__(self):
##         return self.name 
Example 9
Project: django-sqlserver   Author: denisenkom   File: tests.py    License: MIT License 5 votes vote down vote up
def test_big_integer_field(self):
        field = models.BigIntegerField()
        name, path, args, kwargs = field.deconstruct()
        self.assertEqual(path, "django.db.models.BigIntegerField")
        self.assertEqual(args, [])
        self.assertEqual(kwargs, {}) 
Example 10
Project: djongo   Author: nesdis   File: tests.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def test_big_integer_field(self):
        field = models.BigIntegerField()
        name, path, args, kwargs = field.deconstruct()
        self.assertEqual(path, "django.db.models.BigIntegerField")
        self.assertEqual(args, [])
        self.assertEqual(kwargs, {}) 
Example 11
Project: djongo   Author: nesdis   File: test_cast.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def test_cast_to_integer(self):
        for field_class in (
            models.IntegerField,
            models.BigIntegerField,
            models.SmallIntegerField,
            models.PositiveIntegerField,
            models.PositiveSmallIntegerField,
        ):
            with self.subTest(field_class=field_class):
                numbers = Author.objects.annotate(cast_int=Cast('alias', field_class()))
                self.assertEqual(numbers.get().cast_int, 1) 
Example 12
Project: djongo   Author: nesdis   File: tests.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def test_big_integer_field(self):
        field = models.BigIntegerField()
        name, path, args, kwargs = field.deconstruct()
        self.assertEqual(path, "django.db.models.BigIntegerField")
        self.assertEqual(args, [])
        self.assertEqual(kwargs, {}) 
Example 13
Project: djongo   Author: nesdis   File: test_cast.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def test_cast_to_integer(self):
        for field_class in (
            models.AutoField,
            models.BigAutoField,
            models.IntegerField,
            models.BigIntegerField,
            models.SmallIntegerField,
            models.PositiveIntegerField,
            models.PositiveSmallIntegerField,
        ):
            with self.subTest(field_class=field_class):
                numbers = Author.objects.annotate(cast_int=Cast('alias', field_class()))
                self.assertEqual(numbers.get().cast_int, 1) 
Example 14
Project: fcm-django   Author: xtrinch   File: fields.py    License: MIT License 5 votes vote down vote up
def run_validators(self, value):
        # make sure validation is performed on integer value not string value
        value = _hex_string_to_unsigned_integer(value)
        return super(models.BigIntegerField, self).run_validators(value) 
Example 15
Project: MetaCI   Author: SFDO-Tooling   File: testmethod_perf.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def AsInt(expr):
    return Cast(expr, BigIntegerField())