class FilterMealList(views.APIView):
def get(self, request, **kwargs):
user_id = self.kwargs['user_id']
from_time = self.request.GET.get('from_time')
to_time = self.request.GET.get('to_time')
from_date = self.request.GET.get('from_date')
to_date = self.request.GET.get('to_date')
# …
request.GET.get('q', None).
# generics.py
class GenericAPIView(APIView):
...
def dispatch(self, request, *args, **kwargs):
lookup_param = request.GET.get(self.lookup_field, None)
if lookup_param:
kwargs[lookup_field] = lookup_param
return Super(GenericAPIView, self).dispatch(request, *args, **kwargs)
...
#In views.py file:
def get_param(request, param):
my_parameter = param
#In urls.py
path('test/<param>', views.get_param, name='get_param'),
#Then ypu can access with the url: http://localhost:8000/test/test_param