diff options
| author | Tom Christie | 2014-08-18 12:25:03 +0100 | 
|---|---|---|
| committer | Tom Christie | 2014-08-18 12:25:03 +0100 | 
| commit | 8244c7cc33e8d8078529dd0a9a3bdc2ce3a817fc (patch) | |
| tree | f491ade2e908793bbeaacf3b1fbf6190776765fb /rest_framework/generics.py | |
| parent | 0e918055c7c72dc3b6aaa41430c6afa490dd662a (diff) | |
| parent | fc8eb76c2259ea64a19876f040db4d93e834d39d (diff) | |
| download | django-rest-framework-8244c7cc33e8d8078529dd0a9a3bdc2ce3a817fc.tar.bz2 | |
Merge pull request #1711 from kdazzle/ModelViewSet-queryset-static-property
Issue #1707: Add documentation to api-docs.viewsets
Diffstat (limited to 'rest_framework/generics.py')
| -rw-r--r-- | rest_framework/generics.py | 8 | 
1 files changed, 8 insertions, 0 deletions
| diff --git a/rest_framework/generics.py b/rest_framework/generics.py index 7fc9db36..42204841 100644 --- a/rest_framework/generics.py +++ b/rest_framework/generics.py @@ -43,6 +43,10 @@ class GenericAPIView(views.APIView):      # You'll need to either set these attributes,      # or override `get_queryset()`/`get_serializer_class()`. +    # If you are overriding a view method, it is important that you call +    # `get_queryset()` instead of accessing the `queryset` property directly, +    # as `queryset` will get evaluated only once, and those results are cached +    # for all subsequent requests.      queryset = None      serializer_class = None @@ -258,6 +262,10 @@ class GenericAPIView(views.APIView):          This must be an iterable, and may be a queryset.          Defaults to using `self.queryset`. +        This method should always be used rather than accessing `self.queryset` +        directly, as `self.queryset` gets evaluated only once, and those results +        are cached for all subsequent requests. +          You may want to override this if you need to provide different          querysets depending on the incoming request. | 
