diff options
Diffstat (limited to 'rest_framework/generics.py')
| -rw-r--r-- | rest_framework/generics.py | 5 | 
1 files changed, 4 insertions, 1 deletions
| diff --git a/rest_framework/generics.py b/rest_framework/generics.py index 4015ab20..6d204cf5 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} | 
