Django model instances primary keys do not reset to 1 after all instances are deleted

前端 未结 7 626
说谎
说谎 2020-11-29 05:27

I have been working on an offline version of my Django web app and have frequently deleted model instances for a certain ModelX.

I have done this from the admin page

相关标签:
7条回答
  • 2020-11-29 05:59

    I'm not sure when this was added, but the following management command will delete all data from all tables and will reset the auto increment counters to 1.

    ./manage.py sqlflush | psql DATABASE_NAME
    
    0 讨论(0)
提交回复
热议问题