django primary key auto assigning available id from least value

17 Views Asked by At

In django project primary key are assigned automatically. In my model I have some model object with id (=5,6). id (= 1,2,3,4,) is deleted from the DB. Now when I create new object model,django assigning id with the value 7. But I want this to assign in a order like 1,2,3,4 and 7 and so. How can I implement this?

I've tried to create a complete different id field with custom logic to assign the available id first,but I was expecting a django built-in function.

0

There are 0 best solutions below