Django reset auto-increment pk / id field for production

(I'm new to Django, Python, and Postgresql). I added and deleted data in my development and noticed that pk continues to add and never reset to 1, even if I delete all models. Is it possible that reset pk will start at 1 before I push this to production? Is it a good idea to do this?

+4
source share
1 answer

You can reset the sequence of model identifiers with the command sqlsequencereset

python manage.py sqlsequencereset myapp1 myapp2 myapp3| psql

If you want to read the generated sql command, just run this command without passing it to psql.

python manage.py sqlsequencereset myapp1 myapp2 myapp3

. , @knbk, , reset id.

+4

Source: https://habr.com/ru/post/1607025/


All Articles