开发者

ImportError when haystack is added to urls?

When I add the following to my site.urls.py file

#haystack search
url(r'^search/', include('haystack.urls')),

I get this error

Caught ImportError while rendering: No module named urls

here

a href="{% url django.contrib.auth.views.logout %}">Logout</a>

or at the first location of the {% url %} tag, when I comment out the haystack url part, the site 开发者_StackOverflowworks fine.

I'm using python2.7, django1.3, and haystack 1.2.4

What am I doing wrong?

Edit: I tried the same setup on a template file without {% urls %} but still get the No module named urls error. I used easy_install django-haystack, added it to my installed_apps, create a HAYSTACK_SITECONF file and its path in settings.py, why is there no urls for haystack?

Thanks!

No sure what happened but I had to go the the python2.7 folder and rm -rf the haystack folders and pip install them again... and it worked... :|


Ignore the template code and look at the traceback. I've had a few problems where it shows me template code but the error was actually being caused by python code (that you can find in the traceback).

Ensure that haystack is a valid package in your Python path:

Comment out the one line that is problematic and diagnose by creating a new view function:

import sys
# ...
def get_sys_path(request):
    return HttpResponse(str(sys.path))

Add this to your urls.py and access it. Ensure that you can see the haystack directory in one of the paths in sys.path (i.e. the output). If you don't see it, you've probably not installed haystack properly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜