django-tablib icon indicating copy to clipboard operation
django-tablib copied to clipboard

date format on export with TablibAdmin

Open tingletech opened this issue 14 years ago • 3 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?

tingletech avatar Feb 23 '11 02:02 tingletech

This sparks an interesting idea: https://github.com/kennethreitz/tablib/issues/35

kennethreitz avatar Feb 23 '11 03:02 kennethreitz

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

joshourisman avatar Feb 24 '11 13:02 joshourisman

Tablib v0.9.5 was just released, which adds the dataset.add_formatter(column, callback) method.

kennethreitz avatar Mar 24 '11 10:03 kennethreitz