from haystack import indexes import datetime from .models import Query class QueryIndex(indexes.SearchIndex, indexes.Indexable): text = indexes.CharField(document=True, use_template=True) def get_model(self): return Query def index_queryset(self, using=None): """Used when the entire index for model is updated.""" return self.get_model().objects.filter(created_at__lte=datetime.datetime.now())