views:

21

answers:

1

I have this Article model for a news site with a boolean field called "sticky". The idea is that when the author writes an article and marks it as sticky it should always stay at the top of the list of articles. I wrote a template tag and here's my render method:

def render(self, context):
    context[self.varname] = self.model._default_manager.filter(current_issue__isnull=True, issue__isnull=True).live().order_by('-created_at')
    return ''

This query is where I want to aggregate the sticky articles at the top of the list. How do I do this?

+1  A: 

Order by sticky, then order by created_at.

godswearhats
I've tried that, that does not work. When a new article is added it takes over and the sticky one is pushed down.
JeffTaggary
Um? By "pushed down" you mean in your view? If so, how is your view/template working? An alternative would be two have two variables that you pass from your view into your template, one for sticky articles, and one for non-sticky.
godswearhats