【发布时间】:2014-01-22 04:04:52
【问题描述】:
我正在逐行遵循 haystack 教程,但是当我尝试运行命令 rebuild_index 时出现错误 AttributeError: 'CustomerIndex' object has no attribute 'fields'
我已经仔细检查了我的设置文件,我安装的应用程序中有 haystack,我的引擎设置也在那里。
我使用 whoosh 作为我的搜索引擎。 haystack 的版本是 2.1.0,whoosh 的版本是 2.5.6
请帮我摆脱这个错误。
这是我的 search_indexes.py 文件:
import datetime
from haystack import indexes
from customers.models import Customer
class CustomerIndex(indexes.SearchField, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
first_name = indexes.CharField(model_attr='first_name')
create_date = indexes.DateTimeField(model_attr='create_date')
def get_model(self):
return Customer
def index_queryset(self, using=None):
"""
used when the entire index model is updated
"""
return self.get_model()._default_manager.\
filter(create_date__lte=datetime.datetime.now())
【问题讨论】: