Django select max id
I know this already has a right answer but here it's another way of doing it:
prev = Image.objects.last()
This gives you the last object.
Just order by reverse id, and take the top one.
Image.objects.all().order_by("-id")[0]
In current version of django (1.4) it is even more readable
Image.objects.latest('id').id
Your logic is right, this will return the max id
res = Image.objects.filter().aggregate(max_id=Max('pk'))
res.get('max_id')