May i know how to setup method with multiparameter like=>
@action(methods=['get'], detail=True)
def byshiftid(self, request,shiftid):
print("Hello World")
query = self.get_queryset().get(shiftid=shiftid)
serializer = ShiftSummarySerializer(query,many=True)
return Response(serializer.data)
this shiftid
is the parameter.
Here is my router=>
router.register('shifts_mas', ShiftViewSet, base_name='shifts')
Normally my url will be like =>
api/shift_mas/
Now i would like to do like =>
api/shift_mas/byshiftid/?shiftid="shift1"
something like that.
I try like that =>
@action(methods=['get'], detail=True,url_path='/(?P<shiftid>)')
def byshiftid(self, request,shiftid):
print("Hello World")
query = self.get_queryset().get(shiftid=shiftid)
serializer = ShiftSummarySerializer(query,many=True)
return Response(serializer.data)
But its always say 404 not found.
My requirement is to select the record by shiftid
.So how can I setup the route like that?