#NEWLINE# @ list_route ( methods = [ 'get' ] , permission_classes = [ IsAuthenticated ] , url_path = 'list-username' ) #NEWLINE# def list_username( self , request , * args , **kwargs ) : #NEWLINE# #INDENT# pattern = request . query_params . get ( 'pattern' , '$' ) #NEWLINE# user_names = self . queryset . exclude ( username = request . user . username ) . filter ( is_active = True , username__contains = pattern ) #NEWLINE# serializer = UserSerializer ( instance = user_names , many = True , fields = ( 'id' , 'username' ) ) #NEWLINE# return Response ( data = serializer . data , status = status . HTTP_200_OK )