On Thu, Feb 20, 2020 at 11:30 PM Soumen Khatua <soumenkhatua...@gmail.com>
wrote:

> If I'm using serializer then it's working fine but I want to return only
> database object. So for that Do I need to add serializer.
>
You do have to serialize your responses, you just can't send Python objects
as an HTTP response, think about the content-type of your requests

> Thank you for your response.
>
> On Thu 20 Feb, 2020, 11:17 PM MTS BOUR, <mynoveltr...@gmail.com> wrote:
>
>> Can you show us your serializer.py file?
>>
>>
>> Le jeu. 20 févr. 2020 17:40, Soumen Khatua <soumenkhatua...@gmail.com> a
>> écrit :
>>
>>> 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*
>>>
>>> --
>>> 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAPUw6WZh%2BgVfi7URo8vPbpjYfT%3D5AdjGyhntBMLgiZ1msiZECg%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAPUw6WZh%2BgVfi7URo8vPbpjYfT%3D5AdjGyhntBMLgiZ1msiZECg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAAq3G-Ea6aEgo9ECrkbe2Y0bXWGG-GVb-utLf%2B7bn9RCGZ0fGw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAAq3G-Ea6aEgo9ECrkbe2Y0bXWGG-GVb-utLf%2B7bn9RCGZ0fGw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAPUw6WbZ%2BOYqcEpadaxCz_9z45dDpbLRduLuUsgGAg2DyPnhFQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAPUw6WbZ%2BOYqcEpadaxCz_9z45dDpbLRduLuUsgGAg2DyPnhFQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD%3DM5eRXuVv2G-Ld17wydJzPybPo_ccQyoa%2BkQhB4k3nV%3Dz0KQ%40mail.gmail.com.

Reply via email to