[英]'SearchUsers' object has no attribute 'count'
I have problem with this it keeps saying: 'SearchUsers' object has no attribute 'count'我对此有疑问,它一直说:'SearchUsers' object 没有属性'count'
#views #views
from elasticsearch_dsl import Q
class SearchUsers(PaginatedElasticSearchAPIView):
serializer_class = UserSerializer
document_class = UserDocument
def generate_q_expression(self, query):
return Q('bool',
should=[
Q('match', username=query),
Q('match', first_name=query),
Q('match', last_name=query),
], minimum_should_match=1)
#urls #网址
from django.urls import path
from search.views import SearchUsers
urlpatterns = [
path('user/<str:query>/', SearchUsers.as_view()),
]
I'm facing this issue for the last 3 days.我在过去 3 天都面临这个问题。 Searched for the similar question on StackOverflow but nothing helped me.
在 StackOverflow 上搜索了类似的问题,但没有任何帮助。 Any Help, Would be appreciated.
任何帮助,将不胜感激。
Thanks in Advance:)提前致谢:)
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination'
I forget to add in my settings, which I passed through the class parameter.我忘记添加我通过 class 参数传递的设置。 It solved my issue.
它解决了我的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.