Unable to send jwt token as json response
--
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...@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/742f8637-b9e2-4d13-9ea7-0764fb45f5e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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()
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:
--
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...@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.