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.
精彩评论