date format on export with TablibAdmin
tingletech opened this issue · comments
Hi, I'm using TablibAdmin to export from the django admin (on google app engine with django-nonrel if that matters) and a user is complaining that they need the dates in "ISO" CCYY-MM-DD format rather than US "MM/DD/CCYY". I'm not sure if this is a tablib issue or a django issue or a django-tablib issue. Can you give me any hints on how to make this change?
This sparks an interesting idea: https://github.com/kennethreitz/tablib/issues/35
At the moment, the date format actually is configurable. It's using Django's SHORT_DATE_FORMAT setting (as well as django.template.defaultfilters.date) to format datetime objects. So currently the way to configure the date format is to set SHORT_DATE_FORMAT to your desired format in your settings.py. You can see how this works here: https://github.com/joshourisman/django-tablib/blob/master/django_tablib/base.py#L27
Moving forward I want to add Django model/form-field style DatasetFields so that you can easily customize any or all of the fields in your Dataset. So eventually the idea is that you'll be able to do something like this when defining your Dataset:
class MyModelDataset(ModelDataset):
boring_date_field_name = fields.DateField(label="ISO Formatted Date", format="c")
class Meta:
model = MyModel
Tablib v0.9.5 was just released, which adds the dataset.add_formatter(column, callback)
method.