Skip to content

Instantly share code, notes, and snippets.

View notanumber's full-sized avatar

David Sauve notanumber

  • Sauve Software Solutions
  • Victoria, BC
View GitHub Profile
# For Haystack 1.0 or lower
*/15 * * * * cd /path/to/my/site/ && DJANGO_SETTINGS_MODULE=site.settings PYTHONPATH=.:..:../lib python ./manage.py reindex --age=1 > ../../log/search_indexes.log
# For Haystack 1.1 or higher
*/15 * * * * cd /path/to/my/site/ && DJANGO_SETTINGS_MODULE=site.settings PYTHONPATH=.:..:../lib python ./manage.py update_index --age=1 > ../../log/search_indexes.log
def build_query(self):
values = []
return final_query
for child in self.query_filter.children:
if isinstance(child, self.query_filter.__class__):
print 'SQ: ', child # TODO: Recursive call down tree...
else:
expression, value = child
field, filter_type = self.query_filter.split_expression(expression)
from haystack import indexes
class NoSignalSearchIndex(indexes.SearchIndex):
"""
A subclass of haystack's default SearchIndex that overrides the save
and delete signals to prevent them from firing
"""
def _setup_save(self, model):
pass
import haystack
haystack.autodiscover()
haystack.site.static_pages(
('static-about_us', {'template': 'about.html'})
)
diff --git a/haystack/models.py b/haystack/models.py
index ab5f401..7777bf8 100644
--- a/haystack/models.py
+++ b/haystack/models.py
@@ -3,6 +3,7 @@ from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.utils.encoding import force_unicode
from django.utils.text import capfirst
+from django.utils.translation import ugettext_lazy as _
diff --git a/haystack/indexes.py b/haystack/indexes.py
index 95eeb67..5f467a8 100644
--- a/haystack/indexes.py
+++ b/haystack/indexes.py
@@ -1,4 +1,4 @@
-from django.db.models import signals
+from django.db.models import signals, FieldDoesNotExist
import haystack
from haystack.fields import *
def _do_highlight(self, content, text, tag='em'):
"""
Highlight `text` in `content` with html `tag`.
This method assumes that the input text (`content`) does not contain
any special formatting. That is, it does not contain any html tags
or similar markup that could be screwed up by the highlighting.
Required arguments:
`content` -- Content to search for instances of `text`