TinyIntegerField

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
class TinyIntegerField(models.SmallIntegerField):
    def db_type(self, connection):
        if connection.settings_dict['ENGINE'] == 'django.db.backends.mysql':
            return "tinyint"
        else:
            return super(TinyIntegerField, self).db_type(connection)

class PositiveTinyIntegerField(models.PositiveSmallIntegerField):
    def db_type(self, connection):
        if connection.settings_dict['ENGINE'] == 'django.db.backends.mysql':
            return "tinyint unsigned"
        else:
            return super(PositiveTinyIntegerField, self).db_type(connection)

More like this

  1. ByteSplitterField by Lacour 2 years, 8 months ago
  2. Serializing booleans correctly when doing dumpdata from a MySQL database using Django 0.96 by chrj 5 years, 9 months ago
  3. HibernateBooleanField by kivsiak 4 years, 3 months ago
  4. Drop all tables in MySQL database by mpasternacki 4 years, 2 months ago
  5. Arbitrary auto-generated primary keys by gsakkis 3 years, 9 months ago

Comments

(Forgotten your password?)