diff options
| author | Kyle | 2014-07-28 10:11:40 -0700 |
|---|---|---|
| committer | Kyle | 2014-07-28 10:11:40 -0700 |
| commit | e40ffd60d44d736d7e27ff454cba1905f0becc26 (patch) | |
| tree | fdededc77ff5a2720dcf96ca79ddfc9835106827 /rest_framework | |
| parent | 48b02f016a827bc254aba2aedb81b472189c2165 (diff) | |
| download | django-rest-framework-e40ffd60d44d736d7e27ff454cba1905f0becc26.tar.bz2 | |
Issue #1707 - Add documentation about the caching of `GenericAPIView.queryset`
to the `queryset` property, `get_queryset()`, and do generic-views.md; remove
changes to the viewsets.md documentation from my last commit.
Diffstat (limited to 'rest_framework')
| -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 7bac510f..65ccd952 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 @@ -256,6 +260,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. |
