In my models I need to store a mobile number in the following format 447182716281. What field should I use? Does Django have anything to support this?
example
mobile = models.IntegerField(max_length=12)
I think is a interesting question since it really depends on the problem modeling, CharField works fine, but have a look at this:
ORM tricks
On using models.IntegerField(default=0) for larger number it gives error Ensure this value is less than or equal to 2147483647.
So better way to use would be. BigIntegerField A 64-bit integer, much like an IntegerField except that it is guaranteed to fit numbers from -9223372036854775808 to 9223372036854775807. The default form widget for this field is a TextInput.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With