干草堆搜索开始

时间:2011-01-15 22:41:06

标签: python django django-haystack

为什么我使用:

users = SearchQuerySet().all()
users = users.filter(name__startswith='foo')

我有结果查询。当我使用

users = SearchQuerySet().models(UserProfile)
users = users.filter(name__startswith='foo')

我有空查询

Thx:)

1 个答案:

答案 0 :(得分:0)

从您的所有模型中,您创建了SearchIndex?您对SearchIndexUserProfile,例如:

from haystack import indexes
from haystack import site


class UserProfileIndex(indexes.SearchIndex):
    ...

site.register(UserProfile, UserProfileIndex)

您只能看到已编入索引的模型。根据您发布的代码,您似乎没有将UserProfile编入索引,而是将其他模型编入索引。

相关问题