get_a_room/rooms/room_views.py
def filter(self, request):
        """
        Endpoint for filtering rooms by given query params
        """

        ALLOWED_PARAMS = ['is_computer_room', 'capacity', 'min_capacity']
        params = request.query_params.dict()
        filter_params = {}
        for key in params:
            if key in ALLOWED_PARAMS:
                if key == 'is_computer_room':
                    filter_params[key] = params[key] == 'true'
                elif key == 'min_capacity':
                    filter_params['capacity__gte'] = int(params[key])
                else:
                    filter_params[key] = params[key]

        try:
            filtered_set = Room.objects.filter(**filter_params)
        except:
            return Response(
                {'details': 'Invalid query params'},
                status=status.HTTP_400_BAD_REQUEST)

        serializer = RoomSerializer(
            filtered_set, context={'request': request}, many=True)
        return Response(serializer.data)

        Endpoint for filtering rooms by given query params
        
Endpoint for filtering rooms by given query params
Endpoint for filtering rooms by given query params
def filter(self, request):
        ALLOWED_PARAMS = ['is_computer_room', 'capacity', 'min_capacity']
        params = request.query_params.dict()
        filter_params = {}
        for key in params:
            if key in ALLOWED_PARAMS:
                if key == 'is_computer_room':
                    filter_params[key] = params[key] == 'true'
                elif key == 'min_capacity':
                    filter_params['capacity__gte'] = int(params[key])
                else:
                    filter_params[key] = params[key]
        try:
            filtered_set = Room.objects.filter(**filter_params)
        except:
            return Response(
                {'details': 'Invalid query params'},
                status=status.HTTP_400_BAD_REQUEST)
        serializer = RoomSerializer(
            filtered_set, context={'request': request}, many=True)
        return Response(serializer.data)
def filter ( self , request ) : ALLOWED_PARAMS = [ 'is_computer_room' , 'capacity' , 'min_capacity' ] params = request . query_params . dict ( ) filter_params = { } for key in params : if key in ALLOWED_PARAMS : if key == 'is_computer_room' : filter_params [ key ] = params [ key ] == 'true' elif key == 'min_capacity' : filter_params [ 'capacity__gte' ] = int ( params [ key ] ) else : filter_params [ key ] = params [ key ] try : filtered_set = Room . objects . filter ( ** filter_params ) except : return Response ( { 'details' : 'Invalid query params' } , status = status . HTTP_400_BAD_REQUEST ) serializer = RoomSerializer ( filtered_set , context = { 'request' : request } , many = True ) return Response ( serializer . data )
Endpoint for filtering rooms by given query params
Endpoint for filtering rooms by given query params
"""
        Endpoint for filtering rooms by given query params
        """
self
request