Alex Rivera | Logout

get_queryset method and ViewSets in django rest framework

Asked 2013-07-15T09:46:50.023
23

I am doing exactly as the example states

here is my method

class FeedViewSet(viewsets.ModelViewSet):
    model = Feed
    serializer_class = FullFeedSerializer

    def get_queryset(self):
        user = request.user
        queryset = Feed.objects.get_nearby(user)
        return queryset

when i execute it, it says request not defined .. which actually isn't. the example at the rest framework's site also haven't defined request. what am i doing wrong?

Edit
Report

1 Answer

33

The request object is available (on either REST framework's class based views, or Django's standard class based views) as self.request. You're missing the self. part of that.

answered 2013-07-15T10:51:44.933

Your Answer