What's the reason why Django has SmallIntegerField?

Viewed 23826

I'm wonder why it's provided. The field is database dependent, doesn't that make it totally unreliable to use?

I want to store birth year in a model, kinda like

class Person(models.Model):
  name = models.CharField(max_length=256)
  born = models.IntegerField()

Of course this requires very little space, it should always be 4 "characters" long, so a PositiveSmallIntegerField would maybe fit, but why should I choose it instead of normal IntegerField?

5 Answers

The field is database dependent, doesn't that make it totally unreliable to use?

It's not totally unreliable. SMALLINT is part of the SQL standard and certainly MySQL and PostgreSQL both have small integer types that go from -32768 to +32767

Related