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

前端 未结 7 721
说谎
说谎 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:48

    If you are using SQLite you can reset the primary key with the following shell commands:

    DELETE FROM your_table; DELETE FROM SQLite_sequence WHERE name='your_table';

提交回复
热议问题