1

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.

3
  • im not understood whats is error ? Commented Feb 13, 2015 at 9:34
  • do you want to set a filtered queryset? Commented Feb 13, 2015 at 9:43
  • def list(self, request, *args, **kwargs): queryset = ShiftFilters(request.GET,qeryset=Shift.objects.all().order_by('-id')) paginator = Paginator(queryset, 20) page = request.QUERY_PARAMS.get('page') Commented Feb 13, 2015 at 9:46

1 Answer 1

1

Try this:

def list(self, request, *args, **kwargs):
    id = request.QUERY_PARAMS.get('id')
    queryset = Shift.objects.filter(pk=id)
    ...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.