search_indexes.py 670 Bytes
Newer Older
Daniel W Bond's avatar
Daniel W Bond committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
import datetime
from haystack import indexes
from .models import Student

class StudentIndex(indexes.SearchIndex, indexes.Indexable):

    # search results
    # there can BE ONLY ONE document=True per model
    text = indexes.CharField(document=True, use_template=True)
    # the use_template is in the app directory, just a text file
    # with the fields that we want to display when returning results

    # search filtering
    user = indexes.CharField( model_attr = 'user' )

    def get_model(self):
        return Student

    def index_queryset(self, using=None):
        """When the entire index for model is updated."""
	return self.get_model().objects.all()