Mercurial > public > sg101
comparison downloads/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 | 858ce870c854 |
children | cf9918328c64 |
comparison
equal
deleted
inserted
replaced
752:95f4e7f352fd | 753:ad53d929281a |
---|---|
1 """Haystack search index for the downloads application.""" | 1 """Haystack search index for the downloads application.""" |
2 from haystack.indexes import CharField, DateTimeField | 2 from haystack import indexes |
3 from haystack import site | |
4 from custom_search.indexes import PublicQueuedSearchIndex | |
5 | 3 |
6 from downloads.models import Download | 4 from downloads.models import Download |
7 | 5 |
8 | 6 |
9 class DownloadIndex(PublicQueuedSearchIndex): | 7 class DownloadIndex(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='user') | 9 author = indexes.CharField(model_attr='user') |
12 pub_date = DateTimeField(model_attr='date_added') | 10 pub_date = indexes.DateTimeField(model_attr='date_added') |
13 | 11 |
14 def index_queryset(self): | 12 def get_model(self): |
13 return Download | |
14 | |
15 def index_queryset(self, using=None): | |
15 return Download.public_objects.all() | 16 return Download.public_objects.all() |
16 | 17 |
17 def get_updated_field(self): | 18 def get_updated_field(self): |
18 return 'update_date' | 19 return 'update_date' |
19 | |
20 site.register(Download, DownloadIndex) |