In mysql if you want to start your auto-increment key from 2456 you can write AUTO_INCREMENT=2456
Also in PostgreSQL we can do this by using Sequence
CREATE SEQUENCE serial START 2456;
INSERT INTO distributors VALUES (nextval('serial'), 'nothing');
But in Django Rest Framework or Django by default auto-increment starts from 1. If I have a model like this
class Content(models.Model):
title = models.CharField(max_length=70, blank=False, default='')
description = models.CharField(max_length=200,blank=False, default='')
published = models.BooleanField(default=False)
How can I make sure that the first Content starts from 2456?
Create a RunSQL
--(Django Doc) operation
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('sample', '0003_content'),
]
operations = [
migrations.RunSQL(
"ALTER SEQUENCE sample_content_id_seq RESTART WITH 1453"
),
]