Best Practice To Format Output

68 views
Skip to first unread message

Scott Woodall

unread,
Feb 21, 2013, 10:12:41 AM2/21/13
to django-res...@googlegroups.com
I would like to change how dates are displayed in my JSON output. Instead of "2012-12-25" I'd like show "12-25-2012". I've seen some old posts referring to subclass "Resource" or override ".serialize()" but I can't find any references to these in the django rest framework source or documentation. Are these references out of date and if so, is there a preferred way to go about this?

Tom Christie

unread,
Feb 26, 2013, 4:00:50 AM2/26/13
to django-res...@googlegroups.com
At the moment, the right way to do this would be a custom field.
I'd suggest you take a look at the current implementation of DateField, and subclass that.

There's is currently work towards customizing date/time formats, but it's not yet complete...


Cheers,

  Tom

Scott Woodall

unread,
Mar 6, 2013, 12:45:42 PM3/6/13
to django-res...@googlegroups.com
Looks like my procrastination has paid off in spades with todays announcement of 2.2.2 :) Thank you for all the hard work and DRF is a great product.
Reply all
Reply to author
Forward
0 new messages