IS there a method to make Django check for missing id number and create a new item in this slot, instead of making it with a new id.
Here is what am trying to do
I have the model :
class BuyInvoice(models.Model):
date = models.DateTimeField(auto_now_add=True)
user = models.ForeignKey(User, on_delete=PROTECT)
branch = models.ForeignKey(Branch, on_delete=PROTECT)
supplier = models.ForeignKey(Supplier, on_delete=PROTECT)
total = models.PositiveIntegerField(default=0)
is_done = models.BooleanField(default=False)
is_canceled = models.BooleanField(default=False)
def __str__(self):
return 'فاتورة بيع رقم ' + str(self.pk)
whenever I add a new item to it it takes the auto-generated id as 1, 2, 3, 4, 5
now if I deleted the item with the id 3
, then I try to create new item I want it to be added to the id of 3
instead of 6