On the conditional query of django restframework (novice do not spray)

an interface: http://127.0.0.1:8000/api/v1/course/ corresponds to the following processing view

class CourseView(APIView):
    -sharp renderer_classes = [JSONRenderer,]

    def get(self, request, *args, **kwargs):
        ret = {"code": 1}
        try:
            queryset = models.Course.objects.all()
            ser = CourseSerializer(instance=queryset, many=True)
            ret["data"] = ser.data
        except Exception as e:
            ret["code"] = 0
            ret["msg"] = ""
        return Response(ret)

the interface takes no parameters and returns all the data of .all ().

then the problem arises: if I want to write an interface api/products/, this interface, if there are three optional parameters, such as
product name: name (can be vaguely queried), product type: type; production time: time.
if none of the parameters are taken, name returns .all () all data,

how to deal with this problem?

my current idea is:
1 / judge whether to take parameters or not. If there are no parameters, return .all ()
2 / if you have one or more parameters, use .filter (key1 = value1,key2=value2.) Check the data in this form.
thought for a moment, if it is too complicated to judge the parameter logic in this form? Maybe my idea is wrong. Because serializer, such as the above CourseSerializer object instance parameter, needs to pass in a .all () queryset object.

restframework has no components that handle queries like Filter and fuzzy search queries. Do you have any information above?

< hr >

1. Forget all () and use filter () all. filter () when unconditional = all ()
2. What we need now is to judge whether there are conditions.

-sharp time type,. 
name = request.GET.get("name")
type = request.GET.get("type")
time = request.GET.get("time")
-sharp .,filter()
kwargs = {}
if name:
    kwargs["name__contains"] = name
if type:
    kwargs["type"] = type
if time:
    kwargs["time"] = time
queryset = models.Course.objects.filter(**kwargs)
-sharp 
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3602f-2bfea.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3602f-2bfea.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?