My expectation is that even after I delete a record with primary key pk=k
, and later create a new record, this new record will get at least pk=k+1
.
Environment: Python 2.7.8 + Django 1.6.5 + default sqlite3 enginie
My /repeatId/models.py
:
from django.db import models
# Create your models here.
class Foo(models.Model):
name = models.CharField(max_length=30)
def __unicode__(self):
return self.name
manage.py shell
interaction:
>>> from repeatId.models import Foo
>>> Foo.objects.all().count()
0
>>> Foo.objects.create(name='first')
<Foo: first>
>>> Foo.objects.all().count()
1
>>> foo = Foo.objects.all()[0]
>>> foo.id
1
>>> Foo.objects.get(id=1).delete() <--- deleting initial obj with id=1
>>> Foo.objects.all().count()
0
>>> Foo.objects.create(name='second')
<Foo: second>
>>> Foo.objects.all().count()
1
>>> foo = Foo.objects.all()[0]
>>> foo.id <--- expected to get id=2, but got id=1
1