Reputation:
So I have a Django application going and in my models.py I have a field that has models.AutoField(primary_key=True)
. I went into the admin site and deleted some rows off the table, yet when creating a new object the auto-incremented value picked up where it left off instead of going back to 1.
Is there any way I can reset this? I've already tried removing the field, running my migrations, then adding my field back.
Upvotes: 2
Views: 1697
Reputation: 108
You can try using the following command if you are using PostgreSQL.
python manage.py sqlsequencereset AppName| psql DatabaseName
change the AppName to your application name and DatabaseName to your database name.
check also Django reset auto-increment pk/id field for production
Upvotes: 1