On Oct 31, 2017 4:36 AM, "Rakhee Menon" <rakhee.autos...@gmail.com> wrote:



class Login(APIView):

   def post(self, request, *args, **kwargs):
       import ipdb;ipdb.set_trace()
       username = request.POST.get('username')
       password = request.POST.get('password')
       user = Person.objects.get(username=username, password=password)
#        user = user[0]
       #import ipdb;ipdb.set_trace()
       if user:
           payload = {
               'id': user.pk,
               'username': user.username,
               'staff': user.email,
               'exp': datetime.utcnow()


I think that datetime.utcnow() returns a datetime object, not a string, and
I don't think it can be serialized directly. You should try converting that
object to a string in the right format. As a test, substitute a static
string containing a date and time in whatever format you need. I'm not in
front of an interpreter so I can't test, but this seems to back up my
theory:

https://code-maven.com/serialize-datetime-object-as-json-in-python

-James

-- 
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/CA%2Be%2BciUy4yT%2BMsjAdH9pJXfhC4kBkSW832dbuZjqqLKCaKn5fQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to