aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/generics.py
diff options
context:
space:
mode:
authorTom Christie2013-10-21 09:47:07 +0100
committerTom Christie2013-10-21 09:47:07 +0100
commit76672787cdba6a4ab8173b51fa099c910556889b (patch)
tree31f28684b7a84ad64133a01e037d6730fed8e1e1 /rest_framework/generics.py
parentc37bd40d2869892a08722b479a8c56f87332f6fd (diff)
downloaddjango-rest-framework-76672787cdba6a4ab8173b51fa099c910556889b.tar.bz2
Added . Closes #1188.
Diffstat (limited to 'rest_framework/generics.py')
-rw-r--r--rest_framework/generics.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/rest_framework/generics.py b/rest_framework/generics.py
index 4f134bce..f46dea76 100644
--- a/rest_framework/generics.py
+++ b/rest_framework/generics.py
@@ -54,6 +54,7 @@ class GenericAPIView(views.APIView):
# If you want to use object lookups other than pk, set this attribute.
# For more complex lookup requirements override `get_object()`.
lookup_field = 'pk'
+ lookup_url_kwarg = None
# Pagination settings
paginate_by = api_settings.PAGINATE_BY
@@ -278,9 +279,11 @@ class GenericAPIView(views.APIView):
pass # Deprecation warning
# Perform the lookup filtering.
+ # Note that `pk` and `slug` are deprecated styles of lookup filtering.
+ lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field
+ lookup = self.kwargs.get(lookup_url_kwarg, None)
pk = self.kwargs.get(self.pk_url_kwarg, None)
slug = self.kwargs.get(self.slug_url_kwarg, None)
- lookup = self.kwargs.get(self.lookup_field, None)
if lookup is not None:
filter_kwargs = {self.lookup_field: lookup}