django-renjith
django-renjith

Reputation: 4090

django-rest framework filtering error?

Iam trying to implement the web api for shifts , here ShiftsViewSet is my

api view , while running this project im trying to filter according to id , but its showing error ,

ShiftsViewSet' should either include a queryset attribute, or override the get_queryset() method ,

can any one help me to do solve this problem,

thanks in adavance.

Upvotes: 1

Views: 1232

Answers (1)

sc3w
sc3w

Reputation: 1164

Try this:

def list(self, request, *args, **kwargs):
    id = request.QUERY_PARAMS.get('id')
    queryset = Shift.objects.filter(pk=id)
    ...

Upvotes: 1

Related Questions