Hi all. Please help solve the problem. I need to organize search by the
name of chat. But the name of the chat is generated by the serializer
name = serializers.SerializerMethodField('get_chat_name')
"SearchFilter" works with queryset, but the queryset does not have this
field. Because this field added to serializer
class ChatList(generics.ListAPIView):
permission_classes = (permissions.IsAuthenticated,)
serializer_class = ChatSerializers
filter_backends = (SearchFilter,)
search_fields = ('name',)
def get_queryset(self):
user = self.request.user
return Chat.objects.filter(chatusers__user=user)
class ChatSerializers(serializers.ModelSerializer):
name = serializers.SerializerMethodField('get_chat_name')
It is necessary to properly solve this problem. Are ideas?
--
You received this message because you are subscribed to the Google Groups
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.