Closed rptmat57 closed 2 years ago
currently its possible to set the date formating on a per field basis per ViewSet. e.g.
class MyViewSet(XLSXFileMixin, viewsets.ReadOnlyModelViewSet):
xlsx_date_format_mappings = {
'created_at': '%d.%m.%Y %H:%M',
'date': '%d.%m.%Y',
}
I'm open to having it set globally through settings, but currently quite busy…
Yes I noticed that, but it would be a lot to add it for every date field for every model.
I am glad you are open to it, I'll look into it if I have some time.
I was wondering if it would be possible to have global date/time formats, to be set in
settings.py
similar to both django and django rest framework formats:DATETIME_FORMAT
,DATE_FORMAT
,TIME_FORMAT
The reason is that the django rest framework API is more meant to be accessed programmatically, and for that the date format makes sense to be ISO format (standard, easier to parse etc. in many languages)
However, XLSX is meant to be human readable, and ISO format just doesn't make much sense in that regard. Considering dates are stored in UTC a lot, this makes it confusing in Excel and Excel itself doesn't deal with ISO formats.