You can do it like this:
try:
last_inserted = SomeModel.objects.order_by('-id')[0]
print last_inserted.id
except SomeModel.DoesNotExist:
pass
Note that this will throw an error which you should except, if there
are no objects of SomeModel.
Also, I guess, this will fetch all records from the table and will
only get one from the results. So the better approach would be to use
extra() for custom SQL:
http://www.djangoproject.com/documentation/db_api/#extra-select-none-where-none-params-none-tables-none
Good luck!
Aidas Bendoraitis [aka Archatas]
On 11/15/06, Pythoni <[EMAIL PROTECTED]> wrote:
>
> In fact, I mean the last record number
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---