django-ajax-datatable
django-ajax-datatable copied to clipboard
Filter DateTimeField as a string
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?
Have you tried with full date ? 08/08/2017 ? Works for me..
It doesn't filter when using the column search box. But there is some other weird behavior:
- The date displayed in the column is different from the date that appears in the inner table that displays when I click on the row. Update: The date in the column is PST, while the date in the inner table is UTC.
- Some columns seem to only update when there is a matching string literal. But if I type something that doesn't seem to match any value, it just doesn't filter
- The overall search bar is not filtering
I will debug and see if it is an issue with my configuration/setup.
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.