diff options
| author | Tom Christie | 2014-08-20 16:24:52 +0100 | 
|---|---|---|
| committer | Tom Christie | 2014-08-20 16:24:52 +0100 | 
| commit | 9372cc8c31fc5d7b3fb3b155ed88b0b6d3c00049 (patch) | |
| tree | cb9866425b9cbcdcc58fe0254b1f186318560470 /rest_framework/generics.py | |
| parent | 59b47eac14778767a17e56bd8adc0610417f2878 (diff) | |
| download | django-rest-framework-9372cc8c31fc5d7b3fb3b155ed88b0b6d3c00049.tar.bz2 | |
Deprecate .model attribute on views
Diffstat (limited to 'rest_framework/generics.py')
| -rw-r--r-- | rest_framework/generics.py | 11 | 
1 files changed, 11 insertions, 0 deletions
| diff --git a/rest_framework/generics.py b/rest_framework/generics.py index 77deb8e4..a6f68657 100644 --- a/rest_framework/generics.py +++ b/rest_framework/generics.py @@ -252,6 +252,12 @@ class GenericAPIView(views.APIView):          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 " \ @@ -282,6 +288,11 @@ class GenericAPIView(views.APIView):              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()          error_format = "'%s' must define 'queryset' or 'model'" | 
