0

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.

Diego Vinícius
  • 2,125
  • 1
  • 12
  • 23
copser
  • 2,523
  • 5
  • 38
  • 73

2 Answers2

1

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.

Abijith Mg
  • 2,647
  • 21
  • 35
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) 
Sathish Kumar VG
  • 2,154
  • 1
  • 12
  • 19