get_a_room/rooms/booking_views.py
def ondate(self, request):
        """
        Endpoint for filtering booking for given date
        """
        params = request.query_params.dict()
        try:
            date = datetime.datetime.strptime(
                params['date'], "%Y-%m-%d").date()
            day_of_week = DAYS_OF_THE_WEEK[date.weekday()][0]
            bookings = Booking.objects.filter(
                start_date__lte=date,
                end_date__gte=date,
                day_of_week=day_of_week
            )
        except:
            return Response(
                {'details': 'Invalid query params'},
                status=status.HTTP_400_BAD_REQUEST)

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

        Endpoint for filtering booking for given date
        
Endpoint for filtering booking for given date
Endpoint for filtering booking for given date
def ondate(self, request):
        params = request.query_params.dict()
        try:
            date = datetime.datetime.strptime(
                params['date'], "%Y-%m-%d").date()
            day_of_week = DAYS_OF_THE_WEEK[date.weekday()][0]
            bookings = Booking.objects.filter(
                start_date__lte=date,
                end_date__gte=date,
                day_of_week=day_of_week
            )
        except:
            return Response(
                {'details': 'Invalid query params'},
                status=status.HTTP_400_BAD_REQUEST)
        serializer = BookingSerializer(
            bookings, context={'request': request}, many=True)
        return Response(serializer.data)
def ondate ( self , request ) : params = request . query_params . dict ( ) try : date = datetime . datetime . strptime ( params [ 'date' ] , "%Y-%m-%d" ) . date ( ) day_of_week = DAYS_OF_THE_WEEK [ date . weekday ( ) ] [ 0 ] bookings = Booking . objects . filter ( start_date__lte = date , end_date__gte = date , day_of_week = day_of_week ) except : return Response ( { 'details' : 'Invalid query params' } , status = status . HTTP_400_BAD_REQUEST ) serializer = BookingSerializer ( bookings , context = { 'request' : request } , many = True ) return Response ( serializer . data )
Endpoint for filtering booking for given date
Endpoint for filtering booking for given date
"""
        Endpoint for filtering booking for given date
        """
self
request