silentsokolov / django-admin-rangefilter

A Django app that lets you filter data by date range and numeric range in the admin UI
MIT License
721 stars 106 forks source link

Using `settings.USE_TZ = False` on django4.0+ results in error #85

Closed eviljeff closed 2 years ago

eviljeff commented 2 years ago

While updating our project to support django4.0+ I think we've come across a bug. We specify USE_TZ= False in our settings, and the tests for a django admin class that uses DateFilter are now failing under django4.1 with the error: "ValueError: MySQL backend does not support timezone-aware datetimes when USE_TZ is False.".

I believe I've narrowed it down to DateFilter.make_tz_aware https://github.com/silentsokolov/django-admin-rangefilter/blob/v0.8.7/rangefilter/filters.py#L118:L128 where tzinfo is always added as a kwarg under 4.0+, while under previous djangos settings.USE_TZ would need to be truthy for the value to be changed. If I override make_dt_aware to bypass it and just return the value the tests pass again.

silentsokolov commented 2 years ago

Thx, fixed on 0.8.8