On Thu, Jun 4, 2009 at 12:52 PM, josebrwn <joseb...@gmail.com> wrote:
> > Hi, > > I would like to have a list of recent flatpages. I'm doing something > like: > > class LatestCmsNode(template.Node): > def render(self, context): > context['latest_cms'] = FlatPage.objects.all()[:2] > return '' > > > but this orders the results by url (title), and what I want is the > most recent 2 flatpages - ordered by id desc. > > Is there a elegant way to do this, that's simple to understand? > > Thank you! > > Joe > > > > > > Just use the order_by method on a queryset: http://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by-fields Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---