问题
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
回答1:
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.
来源:https://stackoverflow.com/questions/21095825/setting-primary-key-start-value-in-django-model