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

date format on export with TablibAdmin #8

Open
tingletech opened this issue Feb 23, 2011 · 3 comments
Open

date format on export with TablibAdmin #8

tingletech opened this issue Feb 23, 2011 · 3 comments

Comments

@tingletech
Copy link

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?

@kennethreitz
Copy link

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

@joshourisman
Copy link
Owner

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

@kennethreitz
Copy link

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

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

3 participants