12345678910111213141516 |
- from .models import Media
- import datetime
- from haystack import indexes
- class MediaIndex(indexes.SearchIndex, indexes.Indexable):
- text = indexes.CharField(document=True, use_template=True)
- author = indexes.CharField(model_attr='user')
- pub_date = indexes.DateTimeField(model_attr='pub_date')
- def get_model(self):
- return Media
- def index_queryset(self, using=None):
- """Used when the entire index for model is updated."""
- return self.get_model().objects.filter(pub_date__lte=datetime.datetime.now())
|