morlandi / django-ajax-datatable

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

Changing Date formats #107

Closed Palaniyappan12 closed 1 year ago

Palaniyappan12 commented 1 year ago

Hi, This might seem like a simple issue, but thanks in advance for clearing my doubt. I'm currently working on a project, where I've have to include a Datefield in my datatable, but I can't change the default Date format in the Datatable, I found a way(attached below) to solve this, but it seems like a time consuming process. Is there any other way to solve this.

Screenshot 2023-03-11 at 11 22 07 AM

morlandi commented 1 year ago

Hello @Palaniyappan12 since you've already overridden customize_row(), I would try going ahead as follows:

def customize_row(self, row, obj):
    ...
    row['date'] = obj.date.strftime('%Y-%m-%d')

Fully untested ;)

michaeldacanay commented 1 year ago

This changes the date format from 2022-09-15 18:32:27+00:00 to 2022-09-15.