Python django.db.models.BigIntegerField() Examples

The following are 15 code examples of django.db.models.BigIntegerField(). 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 also want to check out all available functions/classes of the module django.db.models , or try the search function .
Example #1
Source File: test_ordinary_fields.py    From djongo with 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
Source File: fields.py    From django-twitter-stream with 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
Source File: models.py    From vortessence with 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
Source File: models.py    From vortessence with 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
Source File: models.py    From vortessence with 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
Source File: models.py    From vortessence with 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
Source File: test_converter.py    From graphene-django with MIT License 5 votes vote down vote up
def test_should_big_integer_convert_int():
    assert_conversion(models.BigIntegerField, graphene.Int) 
Example #8
Source File: models.py    From FFXIVBOT with 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
Source File: tests.py    From django-sqlserver with 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
Source File: tests.py    From djongo with 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
Source File: test_cast.py    From djongo with 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
Source File: tests.py    From djongo with 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
Source File: test_cast.py    From djongo with 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
Source File: fields.py    From fcm-django with 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
Source File: testmethod_perf.py    From MetaCI with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def AsInt(expr):
    return Cast(expr, BigIntegerField())