Source

Ochs / news / search_indexes.py

import datetime
from haystack import indexes
from haystack import site
from news.models import Story

class StoryIndex(indexes.SearchIndex):
    text = indexes.CharField(document=True, use_template=True)
    publish_date = indexes.DateTimeField(model_attr='publish_date')

    def get_queryset(self):
        return Story.objects.filter(publish_date__lte=datetime.datetime.now())
site.register(Story, StoryIndex)