diff options
author | Ernesto Rico-Schmidt <e.rico.schmidt@gmail.com> | 2011-04-02 22:24:41 (GMT) |
---|---|---|
committer | Ernesto Rico-Schmidt <e.rico.schmidt@gmail.com> | 2011-04-02 22:24:41 (GMT) |
commit | e88087eece7104820b60bb11573b579bbb36c01d (patch) | |
tree | dc7ca6aefcd6d11d3097aafc87fbc8330ae3a9db /program | |
parent | 2de89101a2842a069f5c8ef8b577b3a98929517b (diff) |
added search indexes and templates.
Diffstat (limited to 'program')
-rw-r--r-- | program/search_indexes.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/program/search_indexes.py b/program/search_indexes.py new file mode 100644 index 0000000..8c21e14 --- /dev/null +++ b/program/search_indexes.py @@ -0,0 +1,23 @@ +from haystack.indexes import CharField, DateTimeField, SearchIndex +from haystack import site + +from datetime import datetime + +from program.models import Note, Show + +class NoteIndex(SearchIndex): + text = CharField(document=True, use_template=True) + last_updated = DateTimeField(model_attr='last_updated') + + def get_queryset(self): + return Note.objects.filter(last_updated__lte=datetime.now()) + +class ShowIndex(SearchIndex): + text = CharField(document=True, use_template=True) + last_updated = DateTimeField(model_attr='last_updated') + + def get_queryset(self): + return Show.objects.filter(last_updated__lte=datetime.now()) + +site.register(Note, NoteIndex) +site.register(Show, ShowIndex)
\ No newline at end of file |