开发者

haystack search startswith

Why when i use:

users = SearchQuerySet().all()
users = u开发者_开发知识库sers.filter(name__startswith='foo')

i have query with result. And when i use

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

i have empty query

Thx :)


From all your models, in which one did you create a SearchIndex? Do you have a SearchIndex for UserProfile, something like:

from haystack import indexes
from haystack import site


class UserProfileIndex(indexes.SearchIndex):
    ...

site.register(UserProfile, UserProfileIndex)

You can only see models that you have indexed. From the code you've posted, it looks like you haven't indexed UserProfile but some other models.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜