You can use unix timestamp, It's json serializable and can be converted to a datetime object. If I am not wrong you were trying to store it in a session? try this.
import time timestamp=time.time() request.session['current time']= timestamp import datetime datetime.datetime.fromtimestamp(request.session['current time']) On Fri, Aug 3, 2018 at 7:56 PM, Julio Biason <julio.bia...@azion.com> wrote: > Hi Anusha, > > It seems you're trying to generate a JSON of some object/dictionary with a > Datetime in it. Datetimes are not serializable 'cause there is no date/time > representation in JSON (maybe epoch, but that's not the default). > > On Fri, Aug 3, 2018 at 11:18 AM, Anusha Kommineni < > anushakommineni...@gmail.com> wrote: > >> Hi, >> I am getting below error.Can anyone help me? >> >> >> TypeError: datetime.datetime(2018, 2, 12, 0, 0, tzinfo=<UTC>) is not JSON >> serializable >> >> -- >> 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+unsubscr...@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/ms >> gid/django-users/CACBpiKjjH6WhtHfc%3DqLzQ7v5Dc7jDNuAmkRnzB4k >> b9rzE_Rr1Q%40mail.gmail.com >> <https://groups.google.com/d/msgid/django-users/CACBpiKjjH6WhtHfc%3DqLzQ7v5Dc7jDNuAmkRnzB4kb9rzE_Rr1Q%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > *Julio Biason*, Sofware Engineer > *AZION* | Deliver. Accelerate. Protect. > Office: +55 51 3083 8101 <callto:+555130838101> | Mobile: +55 51 > <callto:+5551996209291>*99907 0554* > > -- > 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+unsubscr...@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/CAEM7gE0KV4kLbOnb2Eeinohpa%3D_ > F3MmF7cuo%2BH0N_gYKxG_78g%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAEM7gE0KV4kLbOnb2Eeinohpa%3D_F3MmF7cuo%2BH0N_gYKxG_78g%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- 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+unsubscr...@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/CAMMZq8PcK1Eh7%2B_jR%3DtOnXP4gYSTU%3D4Bz4XUs8K9cizbrYGpBg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.