Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

401
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!