Friday, August 3, 2018

Re: JSON serializable error

> On Aug 3, 2018, at 07:18, Anusha Kommineni <anushakommineni999@gmail.com> wrote:
> TypeError: datetime.datetime(2018, 2, 12, 0, 0, tzinfo=<UTC>) is not JSON serializable

The error means what it says; there is no default way of serializing a datetime into JSON. You can use the DjangoJSONEncoder, which does allow serializing datetimes:

https://docs.djangoproject.com/en/2.0/topics/serialization/#djangojsonencoder

--
-- Christophe Pettus
xof@thebuild.com

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/DCF58620-3F8A-4121-A0FD-7CB3C1922531%40thebuild.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment