Hi Folks,
I'm getting this error, I don't know how to solve it:
File "C:\Users\TildeHat\AppData\Local\Programs\Python\Python38-32\lib\json\encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type User is not JSON serializable
This is my code:
Views.py:
--------------
class LocationApiView(APIView):
permission_classes = (IsAuthenticated,)
def get(self,request,format=None):
user = request.user
user_location = Profile.objects.get(user = user)
return Response({'user':user}, status = status.HTTP_200_OK)
urls.py
----------------
urlpatterns = [
path('api/location/',views.LocationApiView.as_view(),name = 'api_location')
]
btw when I'm sending a normal message it's working fine. But in this case I'm getting this error.
Thank You
Regards,
Soumen