REST framework API through Object of type datetime is not JSON serializable error with auth.backends.RemoteUserBackend

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

REST framework API through Object of type datetime is not JSON serializable error with auth.backends.RemoteUserBackend

bala-2
Hi All,
migrating existing piston based Django api to REST framework api, it works in dev environment but once moved to QA with django.contrib.auth.backends.RemoteUserBackend enabled in settings, getting the following error

raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type datetime is not JSON serializable

To test using the following simple code, once we disable auth.backends.RemoteUserBackend it works

class ApplicationHandler(APIView):
    def get(self, request):
        usernames = [user.username for user in User.objects.all()]
        return Response(usernames)

using Python-3.8 and Django-3.0.3 on RHEL-7, please advice what causes this error and how to resolve it.

thanks,
-bala 

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2086887201.4774514.1605172617681%40mail.yahoo.com.