I think you'll have to sort the list yourself by creating a calculated field, since you're only returning a small number, I don't see this as a big issue.
So, get the records back that you want via the ORM, and then copy them over to a list. HTH John On Feb 20, 6:26 pm, shacker <shac...@birdhouse.org> wrote: > Given a model like: > > class Item(models.Model): > title = models.CharField(max_length=140) > created_date = > models.DateTimeField(default=datetime.datetime.now) > completed = models.BooleanField(default=False) > completed_date = models.DateTimeField(blank=True,null=True) > ... > > I want to create a queryset that retrieves the last 30 Items that were > either created OR completed most recently. In other words, the > created_date and the completed_date fields need to be treated as if > they were a single date field on the model, so that the returned items > would be chronological by either date (completed_date would only be > considered for items where completed=True) > > I've tried both: > > .order_by('-completed_date','-created_date')[:30] > > and > > .order_by('-completed_date').order_by('-created_date')[:30] > > but neither of these are quite right. Not sure what the right approach > to this should be. Suggestions? Thanks. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.