Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

158
Visualizações
SearchQuerySet().filter(content='content') returns results, but they don't show up in search.html

I can go into my shell and type

 sqs = SearchQuerySet().filter(content='content')
 len(sqs)

and I get results. I have inspected them and when I type

 sqs[0]
 sqs[0].id
 sqs[0].text

I get coherent results. However when I use the search form on my website, I get no results.

I don't even define my own SearchView. It is the default one. On the template, I have tried

 {% for result in page.object_list %}
 {% for result in object_list %}
 {% for result in page_obj.object_list %}

and still don't get any results. And the query did run because I can put stuff inside

 {% if query %}

so that clearly works. What do I do?

Thank you.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I resolved this by replacing

  url(r'^search/', include('haystack.urls')),

with

 url(r'^search/?$', views.SearchResultsView.as_view(), name='search-view'),

and making my own SearchResultsView with nothing special in it

 class SearchResultsView(SearchView):
     template_name = 'search/search.html'
     form_class = MySearchForm
     queryset = SearchQuerySet().all()
     paginate_by = 10
     context_object_name = 'object_list'

and using

  page_obj

in the template

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda