it/itf/bestpractices/search_indexes.py

32 lines
1.0 KiB
Python
Raw Normal View History

2011-10-08 00:39:33 +00:00
from haystack.indexes import *
from haystack import site
from models import *
class BestPracticeIndex(SearchIndex):
text = CharField(document=True, use_template=True)
title = CharField(model_attr='title')
story = CharField(model_attr='story')
guideline = CharField(model_attr='guideline')
law = CharField(model_attr='law')
theatre = CharField(model_attr='theatre')
quick_howto = CharField(model_attr='quick_howto')
# pub_date = DateTimeField(model_attr='pub_date')
category = CharField(model_attr='category')
# added = DateTimeField(model_attr='added')
'''
def index_queryset(self):
"""Used when the entire index for model is updated."""
return Note.objects.filter(pub_date__lte=datetime.datetime.now())
'''
2011-10-10 10:30:18 +00:00
class GuidelineIndex(SearchIndex):
text = CharField(document=True, use_template=True)
title = CharField(model_attr='title')
txt = CharField(model_attr='text')
2011-10-08 00:39:33 +00:00
site.register(BestPractice, BestPracticeIndex)
2011-10-10 10:30:18 +00:00
site.register(Guideline, GuidelineIndex)