Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateRangeFilter does not work properly with DateField #130

Open
un1t opened this issue Oct 24, 2024 · 1 comment
Open

DateRangeFilter does not work properly with DateField #130

un1t opened this issue Oct 24, 2024 · 1 comment

Comments

@un1t
Copy link

un1t commented Oct 24, 2024

I use DateRangeFilter with DateField.

When _make_query_filter is executed all seems fine. For example I filter by date 2024-10-24.

self._make_query_filter(request, validated_data)

{
    'date__gte': datetime.datetime(2024, 10, 24, 0, 0, tzinfo=<DstTzInfo 'Asia/Yekaterinburg' LMT+4:03:00 STD>), 
    'date__lte': datetime.datetime(2024, 10, 24, 23, 59, 59, 999999, tzinfo=<DstTzInfo 'Asia/Yekaterinburg' LMT+4:03:00 STD>)
}

But then I looked at SQL query:

> queryset.filter(**self._make_query_filter(request, validated_data)).query.__str__()
'SELECT "orders_order"."id" ..... WHERE ("orders_order"."status" = 1 AND "orders_order"."date" >= 2024-10-24 AND "orders_order"."date" <= 2024-10-25) ORDER BY "orders_order"."id" DESC'

And it is an obvious error.
Expected: "date >= 2024-10-24 AND date" <= 2024-10-24"
Got: "date >= 2024-10-24 AND date <= 2024-10-25"

Package versions:
django-admin-rangefilter==0.13.2
django==5.0.9

@silentsokolov
Copy link
Owner

What db are you using?
Looks like a problem with django sql engine ...
Or with a timezone ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants