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

399
Visualizações
django rest framework - filtering against date query parameter

In my view I'm receiving date parameter and I'm filtering against it so I could show my contact for today, and it goes something like this:

filter_date = self.request.query_params.get('filter_date', None)

for queryset in contact_lead:
   if filter_date is not None:
       queryset = queryset.filter(next_action_date__gte=filter_date)

return queryset

Like I said with this I can see my contacts for today, but there are some contact that are made in the past, now because datepicker have past dates restriction I can not see them and I want all my past contact to appear today, or any other day in the future, so the point is I don't want contact which are created in the past to be left behind, so can someone help me and explain how can I get that result.

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

0

Replace greater than or equal to(__gte) with less than or equal to(__lte) in the query lookup. As shown below:

queryset = queryset.filter(next_action_date__lte=filter_date)

This will fix the issue.

over 4 years ago · Santiago Trujillo Relatório

0

There are two operators to do this one is less than or equal to(__lte)

As given below:

 queryset = queryset.filter(next_action_date__lte=filter_date)

Second one is less than (__le),

This will not give the current Filter Condition

 queryset = queryset.filter(next_action_date__lt=filter_date) 
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