Get the last inserted id in django

Solution 1:

You can get latest create obj like this:

obj = Foo.objects.latest('id')

more info here

Solution 2:

In Django 1.6

obj = Foo.objects.latest('id')

obj = Foo.objects.earliest('id')