View Snippets Error [snippet_detail.html] #15

Closed
matteius opened this Issue Dec 31, 2011 · 6 comments

3 participants

@matteius

Hi, I have spent some time now configuring Django-cab to work with a new website I am developing. So far I have gotten the site mostly functional, with auth logins, and I have used the admin to create a snippet. However I have an issue with viewing the Hello World snippet.

TemplateSyntaxError at /snippets/1/
Caught UnboundLocalError while rendering: local variable 'searcher' referenced before assignment

n template /home/matteius/shared_projects/api_website/api_website/cab/templates/cab/snippet_detail.html, error at line 17
Caught UnboundLocalError while rendering: local variable 'searcher' referenced before assignment7 {% block title %}{{ object.title }}{% endblock %}
8

9 {% block content_header %}{{ object.title }}{% endblock %}
10

11 {% block content %}
12 {{ object.highlighted_code|safe }}
13


14

More like this


15 {% cache 600 mlt object.pk %}
16

    17 {% for related in object|more_like_this:5 %}
    18
  1. {{ related.object.title }} by {{ related.object.author.username }}
    19 {{ related.object.pub_date|timesince }} ago
    20

  2. 21 {% endfor %}
    22

23 {% endcache %}
24

25 {% endblock %}
26

27 {% block sidebar %}

/home/matteius/.virtualenvs/api_website/src/haystack/haystack/backends/whoosh_backend.py in more_like_this
searcher.close()

I did have another issue too when I removed the offending code in the template, however just now I checked and it was resolved, possibly due to specifying a different version of the django tagit depedency, or perhaps it was missing all together. Well this is my current issue has to do with haystack search, and if I remove the offending code the snippet doesn't show up at all?!?

@matteius

Actually ok, I can have the snippet show up by leaving in {{ object.description_html|safe }}

However, what isn't working for me is this code:


More like this


{% cache 600 mlt object.pk %}

    {% for related in object|more_like_this:5 %}
  1. {{ related.object.title }} by {{ related.object.author.username }}
    {{ related.object.pub_date|timesince }} ago

  2. {% endfor %}

{% endcache %}

@matteius

And Also related to this search functionality, searching gets me a template error and I do not find any information about this template:

TemplateDoesNotExist at /search/
search/search.html

@matteius

HAYSTACK_SITECONF = 'search_sites'
HAYSTACK_SEARCH_ENGINE = 'whoosh' # Place where search indexes are stored for snippets - should be non web accessible
HAYSTACK_WHOOSH_PATH = '/tmp/search-index'

@matteius matteius closed this Dec 31, 2011
@coleifer
@matteius

Thanks for the prompt reply. Perhaps "more like this" shouldn't be the default behavior, or there should be a setting to enable this functionality. The documentation doesn't have instructions for setting this up with anything other than woosh. Also please advise on where to look for the search templates.

@matteius matteius reopened this Dec 31, 2011
@zerok
Deutscher Django-Verein e.V. member

It seems like more-like-this by now works with Whoosh and the rest of the ticket is directly related to the cab project and not to djangosnippets.org. So I will close this for now :-)

@zerok zerok closed this Nov 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment