silentsokolov / django-admin-rangefilter

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

From date input gets no value="" #32

Closed saturnus-ringar closed 5 years ago

saturnus-ringar commented 5 years ago

Thanks for a great package, however when I'm using the filter to filter by dates the From date-input gets no value="" in the input. It's just a placeholder with "From date".

This is what the source looks like when I've filtered on 2019-05-01 and 2019-05-30 <input type="text" name="date__gte" class="vDateField" size="10" placeholder="From date" id="id_date__gte">

<input type="text" name="date__lte" value="2019-05-30" class="vDateField" size="10" placeholder="To date" id="id_date__lte">

As you can see the date_gte-input has no value, whereas the date_lte-input has a value.

I'm running Django 2.2.1 and rangefilter 0.3.16, but I had the same problem when I was running Django 1.11.20.

saturnus-ringar commented 5 years ago

I just realized it's because I'm using a DateFieldListFilter on the same field: list_filter = ('date', DateFieldListFilter), ('date', DateRangeFilter)

If I remove the DateFieldListFilter the input gets a value="". It would be great if it would work when there's a DateFieldListFilter in there as well though.

silentsokolov commented 5 years ago

Two filters on one field? Are you sure?

saturnus-ringar commented 5 years ago

Yes. I find the DateFieldListFilter quite convenient to select eg. current month.

silentsokolov commented 5 years ago

Please, update to 0.4.0

saturnus-ringar commented 5 years ago

Works like a charm. Thanks a lot!