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
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`
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 *
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 _
import haystack
haystack.autodiscover()
haystack.site.static_pages(
('static-about_us', {'template': 'about.html'})
)
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
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)
# 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
diff --git a/haystack/indexes.py b/haystack/indexes.py
index 0fc5cd9..441d16d 100644
--- a/haystack/indexes.py
+++ b/haystack/indexes.py
@@ -62,18 +62,6 @@ class SearchIndex(object):
if not len(content_fields) == 1:
raise SearchFieldError("An index must have one (and only one) SearchField with document=True.")
- def _setup_save(self, model):
- signals.post_save.connect(self.update_object, sender=model)
WSGIScriptAlias / /home/mysiteteam/hosting/live.wsgi
WSGIDaemonProcess live user=mysiteteam group=mysiteteam-www-editors threads=1 processes=45
WSGIProcessGroup live
WSGIApplicationGroup %{GLOBAL}
results = sorted(results, key=lambda x:(x.model_name=='foo'), reverse=True)