On Mon, 2008-04-07 at 15:29 -0700, [EMAIL PROTECTED] wrote: > # Note that you can't use 'offset' without 'limit' (on some dbs), so > this doesn't work: > >>> Article.objects.all()[2:] > Traceback (most recent call last): > ... > AssertionError: 'offset' is not allowed without 'limit' > > > I want to get X last entries from a DB like in example above. How can > I specify a "limit" - or what is the easiest way to get X last > objects ? I'm using MySQL, and pre0.97
Order your queryset in the opposite order to what it would normally be and then get the first X entries from that list. Soon there will be a reverse() method on querysets to do this "order in the opposite direction" for you, but for now, just do it manually. Regards, Malcolm -- The early bird may get the worm, but the second mouse gets the cheese. http://www.pointy-stick.com/blog/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---