get_a_room/accounts/views.py
def filter(self, request):
        """
        Filter users by the given query params.
        """
        ALLOWED_PARAMS = {'username', 'role'}
        params = request.query_params.dict()
        params = {
            key: params[key] for key in params if key in ALLOWED_PARAMS
        }
        try:
            filtered_set = User.objects.filter(**params)
        except:
            return Response(
                {'details': 'Invalid query params'},
                status=status.HTTP_400_BAD_REQUEST)
        serializer = UserSerializer(
            filtered_set, context={'request': request}, many=True)
        return Response(serializer.data)

        Filter users by the given query params.
        
Filter users by the given query params.
Filter users by the given query params .
def filter(self, request):
        ALLOWED_PARAMS = {'username', 'role'}
        params = request.query_params.dict()
        params = {
            key: params[key] for key in params if key in ALLOWED_PARAMS
        }
        try:
            filtered_set = User.objects.filter(**params)
        except:
            return Response(
                {'details': 'Invalid query params'},
                status=status.HTTP_400_BAD_REQUEST)
        serializer = UserSerializer(
            filtered_set, context={'request': request}, many=True)
        return Response(serializer.data)
def filter ( self , request ) : ALLOWED_PARAMS = { 'username' , 'role' } params = request . query_params . dict ( ) params = { key : params [ key ] for key in params if key in ALLOWED_PARAMS } try : filtered_set = User . objects . filter ( ** params ) except : return Response ( { 'details' : 'Invalid query params' } , status = status . HTTP_400_BAD_REQUEST ) serializer = UserSerializer ( filtered_set , context = { 'request' : request } , many = True ) return Response ( serializer . data )
Filter users by the given query params.
Filter users by the given query params .
"""
        Filter users by the given query params.
        """
self
request