What's the best way of passing a param using a ModelViewSet? Forexample achieving something like this :
http://127.0.0.1:8000/api/v1/financing-settings/template/?param=block
Below is the approach I was using but found out I have set the param in the body section, but it's not what I want :
class TemplateView(ModelViewSet):
"""ViewSet for Saving Block/ Step template."""
def list(self, request, *args, **kwargs):
"""Get list of Block/Steps with is_process_template is equal to True."""
param = request.data['param']
if param == "block":
_block = Block.objects.filter(is_process_template=True).values()
return JsonResponse({"data": list(_block)}, safe=False, status=200)
elif param == "step":
_step = Step.objects.filter(is_process_template=True).values()
return JsonResponse({"data": list(_step)}, safe=False, status=200)
return Response(status=status.HTTP_204_NO_CONTENT)
request.GET, DRF adds therequest.datadict which is a merge of all GET/POST/FILES data from the request afaik