diff options
| author | Tom Christie | 2014-08-29 12:35:53 +0100 | 
|---|---|---|
| committer | Tom Christie | 2014-08-29 12:35:53 +0100 | 
| commit | b3253b42836acd123224e88c0927f1ee6a031d94 (patch) | |
| tree | 4202bf23aaf5fd900e90a3a66a2e4f80d03e5443 /rest_framework/generics.py | |
| parent | b8c8d10a18741b76355ed7035655d0101c1d778a (diff) | |
| download | django-rest-framework-b3253b42836acd123224e88c0927f1ee6a031d94.tar.bz2 | |
Remove `.model` usage in tests.
Remove the shortcut `.model` view attribute usage from test cases.
Diffstat (limited to 'rest_framework/generics.py')
| -rw-r--r-- | rest_framework/generics.py | 49 | 
1 files changed, 12 insertions, 37 deletions
| diff --git a/rest_framework/generics.py b/rest_framework/generics.py index 09035303..68222864 100644 --- a/rest_framework/generics.py +++ b/rest_framework/generics.py @@ -51,11 +51,6 @@ class GenericAPIView(views.APIView):      queryset = None      serializer_class = None -    # This shortcut may be used instead of setting either or both -    # of the `queryset`/`serializer_class` attributes, although using -    # the explicit style is generally preferred. -    model = None -      # If you want to use object lookups other than pk, set this attribute.      # For more complex lookup requirements override `get_object()`.      lookup_field = 'pk' @@ -71,9 +66,8 @@ class GenericAPIView(views.APIView):      # The filter backend classes to use for queryset filtering      filter_backends = api_settings.DEFAULT_FILTER_BACKENDS -    # The following attributes may be subject to change, +    # The following attribute may be subject to change,      # and should be considered private API. -    model_serializer_class = api_settings.DEFAULT_MODEL_SERIALIZER_CLASS      paginator_class = Paginator      def get_serializer_context(self): @@ -199,26 +193,13 @@ class GenericAPIView(views.APIView):          (Eg. admins get full serialization, others get basic serialization)          """ -        serializer_class = self.serializer_class -        if serializer_class is not None: -            return serializer_class - -        warnings.warn( -            'The `.model` attribute on view classes is now deprecated in favor ' -            'of the more explicit `serializer_class` and `queryset` attributes.', -            DeprecationWarning, stacklevel=2 -        ) - -        assert self.model is not None, \ -            "'%s' should either include a 'serializer_class' attribute, " \ -            "or use the 'model' attribute as a shortcut for " \ -            "automatically generating a serializer class." \ +        assert self.serializer_class is not None, ( +            "'%s' should either include a `serializer_class` attribute, " +            "or override the `get_serializer_class()` method."              % self.__class__.__name__ +        ) -        class DefaultSerializer(self.model_serializer_class): -            class Meta: -                model = self.model -        return DefaultSerializer +        return self.serializer_class      def get_queryset(self):          """ @@ -235,19 +216,13 @@ class GenericAPIView(views.APIView):          (Eg. return a list of items that is specific to the user)          """ -        if self.queryset is not None: -            return self.queryset._clone() - -        if self.model is not None: -            warnings.warn( -                'The `.model` attribute on view classes is now deprecated in favor ' -                'of the more explicit `serializer_class` and `queryset` attributes.', -                DeprecationWarning, stacklevel=2 -            ) -            return self.model._default_manager.all() +        assert self.queryset is not None, ( +            "'%s' should either include a `queryset` attribute, " +            "or override the `get_queryset()` method." +            % self.__class__.__name__ +        ) -        error_format = "'%s' must define 'queryset' or 'model'" -        raise ImproperlyConfigured(error_format % self.__class__.__name__) +        return self.queryset._clone()      def get_object(self):          """ | 
