我刚刚更新到 Haystack 版本 2,并且在尝试执行以前使用 1.7.2 的搜索时收到 ImportError。
cannot import name site
追溯:
Traceback:
File "/Users/nb/Desktop/myenv2/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/Users/nb/Desktop/nutmegstore/apps/haystack/views.py" in __call__
45. self.form = self.build_form()
File "/Users/nb/Desktop/nutmegstore/apps/haystack/views.py" in build_form
72. return self.form_class(data, **kwargs)
File "/Users/nb/Desktop/nutmegstore/apps/haystack/forms.py" in __init__
90. self.fields['models'] = forms.MultipleChoiceField(choices=model_choices(), required=False, label=_('Search In'), widget=forms.CheckboxSelectMultiple)
File "/Users/nb/Desktop/nutmegstore/apps/haystack/forms.py" in model_choices
12. choices = [("%s.%s" % (m._meta.app_label, m._meta.module_name), capfirst(smart_unicode(m._meta.verbose_name_plural))) for m in connections[using].get_unified_index().get_indexed_models()]
File "/Users/nb/Desktop/nutmegstore/apps/haystack/utils/loading.py" in get_indexed_models
268. self.build()
File "/Users/nb/Desktop/nutmegstore/apps/haystack/utils/loading.py" in build
197. indexes = self.collect_indexes()
File "/Users/nb/Desktop/nutmegstore/apps/haystack/utils/loading.py" in collect_indexes
166. search_index_module = importlib.import_module("%s.search_indexes" % app)
File "/Users/nb/Desktop/myenv2/lib/python2.7/site-packages/django/utils/importlib.py" in import_module
35. __import__(name)
File "/Users/nb/Desktop/nutmegstore/nutmegmodels/search_indexes.py" in <module>
3. from haystack import site
Exception Type: ImportError at /search/
Exception Value: cannot import name site