Logo Questions Linux Laravel Mysql Ubuntu Git Menu

Setting primary key start value in Django model

I am preparing a model as follows:

class SomeModel(models.Model):
    id = models.BigIntegerField(primary_key=True, null=False, unique=True)

But my primary key must be a valid 9+ digit integer value. If I set the start index as 100000000. then any value generated as id will be 9 digit or greater in length.

But django do not support this. How can I implement this with minimum direct interference to django?

I am using Django 1.3 and Postgresql 9.1

like image 523
FallenAngel Avatar asked Feb 14 '23 03:02


1 Answers

I'm not a django user but I think the postgresql command you are looking for is:

ALTER SEQUENCE big_integer_seq RESTART 100000000;

Best to read the documentation for django/postgresql.

like image 112
Melbourne2991 Avatar answered Feb 17 '23 21:02