Mercurial > public > sg101
comparison news/search_indexes.py @ 753:ad53d929281a
For issue #62, upgrade Haystack from 1.2.7 to 2.1.0.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Fri, 03 Jan 2014 19:01:18 -0600 |
parents | ee87ea74d46b |
children | cf9918328c64 |
comparison
equal
deleted
inserted
replaced
752:95f4e7f352fd | 753:ad53d929281a |
---|---|
1 """Haystack search index for the news application.""" | 1 """Haystack search index for the news application.""" |
2 from haystack.indexes import * | 2 from haystack import indexes |
3 from haystack import site | |
4 from custom_search.indexes import CondQueuedSearchIndex | |
5 | 3 |
6 from news.models import Story | 4 from news.models import Story |
7 | 5 |
8 | 6 |
9 class StoryIndex(CondQueuedSearchIndex): | 7 class StoryIndex(indexes.SearchIndex, indexes.Indexable): |
10 text = CharField(document=True, use_template=True) | 8 text = indexes.CharField(document=True, use_template=True) |
11 author = CharField(model_attr='submitter') | 9 author = indexes.CharField(model_attr='submitter') |
12 pub_date = DateTimeField(model_attr='date_submitted') | 10 pub_date = indexes.DateTimeField(model_attr='date_submitted') |
11 | |
12 def get_model(self): | |
13 return Story | |
13 | 14 |
14 def get_updated_field(self): | 15 def get_updated_field(self): |
15 return 'update_date' | 16 return 'update_date' |
16 | |
17 | |
18 site.register(Story, StoryIndex) |