title: Return String if object Existed Function in Django Rest Framework
body: <p>I have a question about <strong>Function</strong> which Return String if object Existed in Django Rest Framework.</p>
  
  <p>I want to set condition:
  If FriendshipRequest model have <code>from_user = request.user</code> and <code>to_user=self.user</code>, this relationship_to_user fields will return: 'Existed', if not, print 'Not Existed'</p>
  
  <p>Code in <strong>Serializers:</strong></p>
  
  <pre><code>class UserDetailSerializer(ModelSerializer):
      relationship_to_user = SerializerMethodField()
      class Meta:
          model = User
          fields = [
              'id',
              'relationship_to_user',
          ]
  
      def get_relationship_to_user(self, instance):
        request = self.context.get('request')
        if FriendshipRequest.objects.filter(from_user=request.user, to_user=instance).exist():
            return 'Existed'
        else:
            return 'Not Existed'
  </code></pre>
  
  <p>This code is in <strong>Viewset.py</strong></p>
  
  <pre><code>class UserDetailAPIView(RetrieveAPIView):
      queryset = User.objects.all()
      serializer_class = UserDetailSerializer
      lookup_field = 'username'
  
      def retrieve(self, request, *args, **kwargs):
          to_user = self.get_object()
          serializer = UserDetailSerializer(to_user, context={'request': request})
          return Response(serializer.data)
  </code></pre>
  
  <p><strong>Issues Traceback:</strong> get</p>
  
  <pre><code> File "C:\Python27\lib\site-packages\django\core\handlers\exception.py" in inner
    41.             response = get_response(request)
  
  File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in _get_response
    187.                 response = self.process_exception_by_middleware(e, request)
  
  File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in _get_response
    185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)
  
  File "C:\Python27\lib\site-packages\django\views\decorators\csrf.py" in wrapped_view
    58.         return view_func(*args, **kwargs)
  
  File "C:\Python27\lib\site-packages\django\views\generic\base.py" in view
    68.             return self.dispatch(request, *args, **kwargs)
  
  File "C:\Python27\lib\site-packages\rest_framework\views.py" in dispatch
    489.             response = self.handle_exception(exc)
  
  File "C:\Python27\lib\site-packages\rest_framework\views.py" in handle_exception
    449.             self.raise_uncaught_exception(exc)
  
  File "C:\Python27\lib\site-packages\rest_framework\views.py" in dispatch
    486.             response = handler(request, *args, **kwargs)
  
  File "C:\Python27\lib\site-packages\rest_framework\generics.py" in get
    210.         return self.retrieve(request, *args, **kwargs)
  
  File "C:\Users\User\Desktop\FeedGit\backend\api\authentication\views.py" in retrieve
    35.         return Response(serializer.data)
  
  File "C:\Python27\lib\site-packages\rest_framework\serializers.py" in data
    534.         ret = super(Serializer, self).data
  
  File "C:\Python27\lib\site-packages\rest_framework\serializers.py" in data
    263.                 self._data = self.to_representation(self.instance)
  
  File "C:\Python27\lib\site-packages\rest_framework\serializers.py" in to_representation
    501.                 ret[field.field_name] = field.to_representation(attribute)
  
  File "C:\Python27\lib\site-packages\rest_framework\fields.py" in to_representation
    1755.         return method(value)
  
  File "C:\Users\User\Desktop\FeedGit\backend\api\authentication\serializers.py" in get_relationship_to_user
    166.         if FriendshipRequest.objects.filter(from_user=request.user, to_user=instance).exist():
  
  Exception Type: AttributeError at /api/v1/users/duongnuhabang/
  Exception Value: 'QuerySet' object has no attribute 'exist'
  </code></pre>