Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Serialize DateTimeField as formated string

69 views
Skip to first unread message

Fillippe Chiniara

unread,
Apr 3, 2023, 4:08:13 PM4/3/23
to MongoEngine Users
Hey all.

I am working with some EmbeddedDocuments that have DateTimeFields in them.
The thing is:
When I get the data from the database and use to_json() I get stuff like

{
  "name": foo
  "updated" {
    "$date": 1231267312673
  }
}

But i wanted something like:

{
  "name": foo
  "updated": "2023-04-03T17:07:32.0000Z"
}

I have searched through the docs and google but couldn't find a way to do this.


Reply all
Reply to author
Forward
0 new messages