Note that there are some explanatory texts on larger screens.

plurals
  1. POCustomize view with Whoosh
    primarykey
    data
    text
    <p>I'm using Haystack and Whoosh to build the search engine part of a site. Whoosh works very well in my case but i need to show an extra information from my view depends on what the search found.</p> <p>In my Django view i use something like this, where dummy is the information to show:</p> <pre><code> dummy = "dummy" return render_to_response('images/ib_large_image.html', {'dummy': dummy}, context_instance=RequestContext(request)) </code></pre> <p>So, basically i want to personalize the view of the search to show my variable into the search template. </p> <p>Here are some configuration:</p> <p><strong>settings</strong>:</p> <pre><code> HAYSTACK_CONNECTIONS = { 'default': { 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine', 'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'), 'DEFAULT_OPERATOR': 'AND', 'SITECONF': 'search_sites', 'SEARCH_RESULTS_PER_PAGE': 20 }, } </code></pre> <p><strong>search_sites.py</strong>:</p> <pre><code> import haystack haystack.autodiscover() </code></pre> <p><strong>search > indexes > imageboard > image_text.txt</strong>:</p> <pre><code> {{ object.name }} {{ object.description }} </code></pre> <p><strong>imageboard > search_indexes.py</strong>:</p> <pre><code> import datetime from haystack import indexes from imageboard.models import Image class ImageIndex(indexes.SearchIndex, indexes.Indexable): text = indexes.CharField(document=True, use_template=True) def get_model(self): return Image def index_queryset(self): """Used when the entire index for model is updated.""" return self.get_model().objects.filter(uploaded_date__lte=datetime.datetime.now()) </code></pre> <p><strong>imageboard > urls.py</strong>:</p> <pre><code> urlpatterns = patterns('imageboard.views', (r'^search/', include('haystack.urls')), ) </code></pre> <p>I configured my view like this, but it doesn't work:</p> <p><strong>imageboard > views.py</strong>:</p> <pre><code> from haystack.views import SearchView def search(request): return SearchView(template='search.html')(request) </code></pre> <p>Any idea??</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload