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

15 views
Skip to first unread message

bala

unread,
Nov 12, 2020, 10:27:25 AM11/12/20
to django...@googlegroups.com
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 

Reply all
Reply to author
Forward
0 new messages