我在Django上创建我的博客,我想基于django-haystack添加网站搜索.我使用官方手册制作了干草堆的基本配置,但是当我想测试我的搜索时,我收到一个错误:'选项'对象没有属性'_fields'
以下是我的一些配置:
search_indexes.pyclass PostIndex(indexes.SearchIndex, indexes.Indexable): text = indexes.CharField(document=True, use_template=True) title = indexes.CharField(model_attr='title') pub_date = indexes.DateTimeField(model_attr='date') def get_model(self): return Post def index_queryset(self, using=None): """Used when the entire index for model is updated.""" return self.get_model().objects.all()settings.py
HAYSTACK_CONNECTIONS = { 'default': { 'ENGINE': 'haystack.backends.simple_backend.SimpleEngine', }, } HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
所以这是我的问题.有没有人与smth相似?提前致谢!
您正在使用git中修复的简单后端中的错误.但是,似乎没有包含此修复程序的发行版,因此您可以升级到开发版本:
pip install -e git+https://github.com/toastdriven/django-haystack.git@master#egg=django-haystack
或者使用不同的后端(elasticsearch,solr,...)