Django BigInteger auto-increment field as primary key?
Posted
by Alex Letoosh
on Stack Overflow
See other posts from Stack Overflow
or by Alex Letoosh
Published on 2010-04-20T06:19:55Z
Indexed on
2010/04/20
6:23 UTC
Read the original article
Hit count: 463
Hi all,
I'm currently building a project which involves a lot of collective intelligence. Every user visiting the web site gets created a unique profile and their data is later used to calculate best matches for themselves and other users.
By default, Django creates an INT(11) id
field to handle models primary keys. I'm concerned with this being overflown very quickly (i.e. ~2.4b devices visiting the page without prior cookie set up). How can I change it to be represented as BIGINT in MySQL and long() inside Django itself?
I've found I could do the following (http://docs.djangoproject.com/en/dev/ref/models/fields/#bigintegerfield):
class MyProfile(models.Model):
id = BigIntegerField(primary_key=True)
But is there a way to make it autoincrement, like usual id
fields? Additionally, can I make it unsigned so that I get more space to fill in?
Thanks!
© Stack Overflow or respective owner