Created
November 21, 2018 23:25
-
-
Save nitely/97c9123900e9bec66340b0b183cf0819 to your computer and use it in GitHub Desktop.
django serialize_datetime for javascript and json consumption
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def serialize_datetime(dt): | |
return ( | |
dt.astimezone(timezone.get_default_timezone()) | |
.isoformat() | |
.replace('+00:00', 'Z')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment