morlandi / django-ajax-datatable

A Django app which provides the integration of a Django project with the jQuery Javascript library DataTables.net
MIT License
211 stars 64 forks source link

Filter DateTimeField as a string #109

Open michaeldacanay opened 1 year ago

michaeldacanay commented 1 year ago

The column search box does not work for DateTimeField. For example, intuitively a column with value 08/07/2017 17:03:28 should match "8/07" or "2017". However, the table becomes empty and "No data available in table" is displayed instead. Is there a way to treat the date as a string, similar to how foreign_field option allowed for filtering a foreign key?

cnagytcorp commented 1 year ago

Have you tried with full date ? 08/08/2017 ? Works for me.. image

michaeldacanay commented 1 year ago

It doesn't filter when using the column search box. But there is some other weird behavior:

I will debug and see if it is an issue with my configuration/setup.

michaeldacanay commented 1 year ago

For example, if a date model has a field:

created_date = models.DateTimeField(auto_now_add=True)

The value in the inner table looks like "2022-09-15 18:32:27+00:00". I tried 2022-09-15, 09/15/2022, even the full date string but all don't work. Additionally, if I make the column a select drop-down, it does not seem to match any records.

image