diff options
| author | Tom Christie | 2015-02-06 14:35:06 +0000 | 
|---|---|---|
| committer | Tom Christie | 2015-02-06 14:35:06 +0000 | 
| commit | 3dff9a4fe2952cf632ca7f4cd9ecf4221059ca91 (patch) | |
| tree | 0649d42b20b875e97cb551b987644b61e7860e84 /rest_framework/views.py | |
| parent | c06a82d0531f4cb290baacee196829c770913eaa (diff) | |
| parent | 1f996128458570a909d13f15c3d739fb12111984 (diff) | |
| download | django-rest-framework-model-serializer-caching.tar.bz2 | |
Resolve merge conflictmodel-serializer-caching
Diffstat (limited to 'rest_framework/views.py')
| -rw-r--r-- | rest_framework/views.py | 15 | 
1 files changed, 9 insertions, 6 deletions
| diff --git a/rest_framework/views.py b/rest_framework/views.py index 12bb78bd..b4abc4d9 100644 --- a/rest_framework/views.py +++ b/rest_framework/views.py @@ -2,12 +2,11 @@  Provides an APIView class that is the base of all views in REST framework.  """  from __future__ import unicode_literals -import inspect -import warnings -  from django.core.exceptions import PermissionDenied  from django.http import Http404 +from django.utils import six  from django.utils.encoding import smart_text +from django.utils.translation import ugettext_lazy as _  from django.views.decorators.csrf import csrf_exempt  from rest_framework import status, exceptions  from rest_framework.compat import HttpResponseBase, View @@ -15,6 +14,8 @@ from rest_framework.request import Request  from rest_framework.response import Response  from rest_framework.settings import api_settings  from rest_framework.utils import formatting +import inspect +import warnings  def get_view_name(view_cls, suffix=None): @@ -74,11 +75,13 @@ def exception_handler(exc, context):          return Response(data, status=exc.status_code, headers=headers)      elif isinstance(exc, Http404): -        data = {'detail': 'Not found'} +        msg = _('Not found.') +        data = {'detail': six.text_type(msg)}          return Response(data, status=status.HTTP_404_NOT_FOUND)      elif isinstance(exc, PermissionDenied): -        data = {'detail': 'Permission denied'} +        msg = _('Permission denied.') +        data = {'detail': six.text_type(msg)}          return Response(data, status=status.HTTP_403_FORBIDDEN)      # Note: Unhandled exceptions will raise a 500 error. @@ -406,7 +409,7 @@ class APIView(View):              warnings.warn(                  'The `exception_handler(exc)` call signature is deprecated. '                  'Use `exception_handler(exc, context) instead.', -                PendingDeprecationWarning +                DeprecationWarning              )              response = exception_handler(exc)          else: | 
