11👍
Adding this as an answer. Django maps this to serial columns which means that the maximum value is in the 2 billion range ( 2,147,483,647 to be exact). While that is unlikely to be an issue for most applications, if you do, you could alter the type to become a bigint instead and this would make it highly unlikely you will ever reach the end of 64-bit int space.
11👍
Adding new info for Django 2.x
:
Djangos AutoField
is an IntegerField
. The docs for IntegerField
say:
Values from
-2.147.483.648
to2.147.483.647
are safe in all databases supported by Django.
AutoField
per default only uses positive numbers, so the values can go from 1
to 2.147.483.647
.
Since Django 1.10
there is also an BigAutoField
, which is very similar to the BigIntegerField
.
The docs for BigAutoField
say:
A 64-bit integer […] that is guaranteed to fit numbers from
1
to9.223.372.036.854.775.807
.
Now, the docs don’t say it explicitly for this field, but by using the words is garanteed to fit
, I assume that applies for all databases supported by Django.
- Python + Django on Android
- How to I hide my secret_key using virtualenv and Django?
- How to reset virtualenv and pip?
- How do I generate models for an existing database in Django?
- How to render a Django form with RadioSelect without getting a checked radiobutton by default?
1👍
As others have mentioned whether you use int
or bigint
, respectively you have 2.147.483.648
or 9.223.372.036.854.775.808
values.
If you think to exceed those numbers, you can do sharding.
In short, sharding is a way of horizontally partitioning your data by storing different rows of the same table in multiple tables across multiple databases.
There are available many sharding libraries for Django (e.g. django-sharding)
- "Apps aren't loaded yet" when trying to run pytest-django
- Model self-dependency (one-to-many field) implementation
- Pymongo [SSL: CERTIFICATE_VERIFY_FAILED]: certificate has expired on Mongo Atlas
- Sphinx-apidoc on django build html failure on `django.core.exceptions.AppRegistryNotReady`
- Celery – minimize memory consumption