我无法恢复结果。
这是我到目前为止所得到的:
search_indexes.py
class CompanyIndex(SearchIndex):
text = CharField(document=True, use_template=True)
name = CharField(model_attr='name')
sector = CharField(model_attr='sector')
def get_model(self):
return Company
def index_queryset(self):
return self.get_model().objects.all()
site.register(公司,公司索引)
class CompanySearchForm(ModelSearchForm):
name = forms.CharField(max_length=64, required=False)
sector = forms.MultipleChoiceField(choices=SECTORS_CHOICES, required=False)
def search(self):
# First, store the SearchQuerySet received from other processing.
sqs = super(CompanySearchForm, self).search()
print "fgdgdfgdfgdfg"
if self.is_valid():
# Check to see if a start_date was chosen.
if self.cleaned_data['name']:
print "%s" % self.cleaned_data['name']
sqs = sqs.filter(name__exact=self.cleaned_data['name'])
# Check to see if an end_date was chosen.
if self.cleaned_data['sector']:
sqs = sqs.filter(sector__contains=self.cleaned_data['sector'])
return sqs
和网址:
sqs = SearchQuerySet()
url(r'^search/', SearchView(
template='search/search.html',
form_class=CompanySearchForm,
searchqueryset=sqs,
), name='haystack_search'),
我正在使用 haystack 文档中的模板。我没有看到任何结果。
我很感激任何帮助