Hi Tom, thanks for getting back to me.

As said, it is super weird:
both start_date and end_date are both datetime.datetime.

furthermore the queryset is as said non-empty:
<QuerySet [{'id': 9, 'account_id': 4, 'organization_id': 11, 'office_id':
1, 'booking_time': datetime.datetime(2021, 3, 20, 0, 0, tzinfo=<UTC>),
'location': 'H'}, {'id': 10, 'account_id': 4, 'organization_id': 11,
'office_id': 1, 'booking_time': datetime.datetime(2021, 3, 21, 0, 0,
tzinfo=<UTC>), 'location': 'H'}]>

However, it is not working, and then if I remove the __range (see initial
question): I have this queryset (while the above queryset is obviously
included in the below one):
<QuerySet [{'id': 4, 'account_id': 12, 'organization_id': 11, 'office_id':
1, 'booking_time': datetime.datetime(2021, 3, 24, 23, 0, tzinfo=<UTC>),
'location': 'H'}, {'id': 2, 'account_id': 12, 'organization_id': 11,
'office_id': 1, 'booking_time': datetime.datetime(2021, 3, 18, 23, 0,
tzinfo=<UTC>), 'location': 'H'}, {'id': 3, 'account_id': 2,
'organization_id': 11, 'office_id': 1, 'booking_time':
datetime.datetime(2021, 3, 18, 0, 0, tzinfo=<UTC>), 'location': 'H'},
{'id': 8, 'account_id': 3, 'organization_id': 11, 'office_id': 1,
'booking_time': datetime.datetime(2021, 3, 18, 0, 0, tzinfo=<UTC>),
'location': 'H'}, {'id': 9, 'account_id': 4, 'organization_id': 11,
'office_id': 1, 'booking_time': datetime.datetime(2021, 3, 20, 0, 0,
tzinfo=<UTC>), 'location': 'H'}, {'id': 10, 'account_id': 4,
'organization_id': 11, 'office_id': 1, 'booking_time':
datetime.datetime(2021, 3, 21, 0, 0, tzinfo=<UTC>), 'location': 'H'}]>

I am really clueless why this is happening.
Do I need to think about something specific in the template when filtering
for dates?

sent from my phone.
sorry for typos.

On Fri, 19 Mar 2021, 20:21 Thomas Lockhart, <tlockhart1...@gmail.com> wrote:

> Almost certainly start_date and end_date are not what you expect.
>
> Do the types match? In any case print them out and see what you are
> actually getting.
>
> hth
>
> - Tom
>
> On Mar 19, 2021, at 6:00 AM, Manuel Buri <manuel.b...@gmail.com> wrote:
>
> Hi,
>
> I am having this query set in my view:
> context['bookings']=Booking.objects.filter(
> Q(organization_id=request.user.organization_id), *Q(booking_time__range=
> (start_date, end_date))*)
>
> It produces a *non-empty* query set!
> However, I am NOT able to display it in my template.
>
> If I get *rid* of Q(booking_time__range= (start_date, end_date) and only
> do:
>
> context['bookings']=Booking.objects.filter( 
> Q(organization_id=request.user.organization_id))
> then it is also non-empty AND it is displaying it in my template.
>
> *What am I missing here?*
>
> Thank you for your help.
>
> Manuel
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/76f85c72-19f9-4ad3-a39b-01dc60aa6da5n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/76f85c72-19f9-4ad3-a39b-01dc60aa6da5n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/2DC9EY75yuM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/83B24C06-8DA4-4F38-9384-FF4C19DBE262%40gmail.com
> <https://groups.google.com/d/msgid/django-users/83B24C06-8DA4-4F38-9384-FF4C19DBE262%40gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACx7KOQ%3DUGG%3DDxAzJR-6mbruUoDB4HmpdG0zW2zrBCJcOvi42g%40mail.gmail.com.

Reply via email to