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

Filter DateTimeField as a string #109

Open
michaeldacanay opened this issue Mar 13, 2023 · 3 comments
Open

Filter DateTimeField as a string #109

michaeldacanay opened this issue Mar 13, 2023 · 3 comments

Comments

@michaeldacanay
Copy link

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
Copy link

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

@michaeldacanay
Copy link
Author

michaeldacanay commented Mar 14, 2023

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.

@michaeldacanay
Copy link
Author

michaeldacanay commented Mar 18, 2023

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

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