mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 08:14:16 +03:00
Use view.settings for API settings, to make testing easier.
This commit is contained in:
parent
b430503fa6
commit
b54cbd292c
|
@ -79,8 +79,8 @@ def exception_handler(exc):
|
||||||
|
|
||||||
|
|
||||||
class APIView(View):
|
class APIView(View):
|
||||||
settings = api_settings
|
|
||||||
|
|
||||||
|
# The following policies may be set at either globally, or per-view.
|
||||||
renderer_classes = api_settings.DEFAULT_RENDERER_CLASSES
|
renderer_classes = api_settings.DEFAULT_RENDERER_CLASSES
|
||||||
parser_classes = api_settings.DEFAULT_PARSER_CLASSES
|
parser_classes = api_settings.DEFAULT_PARSER_CLASSES
|
||||||
authentication_classes = api_settings.DEFAULT_AUTHENTICATION_CLASSES
|
authentication_classes = api_settings.DEFAULT_AUTHENTICATION_CLASSES
|
||||||
|
@ -88,6 +88,9 @@ class APIView(View):
|
||||||
permission_classes = api_settings.DEFAULT_PERMISSION_CLASSES
|
permission_classes = api_settings.DEFAULT_PERMISSION_CLASSES
|
||||||
content_negotiation_class = api_settings.DEFAULT_CONTENT_NEGOTIATION_CLASS
|
content_negotiation_class = api_settings.DEFAULT_CONTENT_NEGOTIATION_CLASS
|
||||||
|
|
||||||
|
# Allow dependancy injection of other settings to make testing easier.
|
||||||
|
settings = api_settings
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def as_view(cls, **initkwargs):
|
def as_view(cls, **initkwargs):
|
||||||
"""
|
"""
|
||||||
|
@ -178,7 +181,7 @@ class APIView(View):
|
||||||
Return the view name, as used in OPTIONS responses and in the
|
Return the view name, as used in OPTIONS responses and in the
|
||||||
browsable API.
|
browsable API.
|
||||||
"""
|
"""
|
||||||
func = api_settings.VIEW_NAME_FUNCTION
|
func = self.settings.VIEW_NAME_FUNCTION
|
||||||
return func(self.__class__, getattr(self, 'suffix', None))
|
return func(self.__class__, getattr(self, 'suffix', None))
|
||||||
|
|
||||||
def get_view_description(self, html=False):
|
def get_view_description(self, html=False):
|
||||||
|
@ -186,7 +189,7 @@ class APIView(View):
|
||||||
Return some descriptive text for the view, as used in OPTIONS responses
|
Return some descriptive text for the view, as used in OPTIONS responses
|
||||||
and in the browsable API.
|
and in the browsable API.
|
||||||
"""
|
"""
|
||||||
func = api_settings.VIEW_DESCRIPTION_FUNCTION
|
func = self.settings.VIEW_DESCRIPTION_FUNCTION
|
||||||
return func(self.__class__, html)
|
return func(self.__class__, html)
|
||||||
|
|
||||||
# API policy instantiation methods
|
# API policy instantiation methods
|
||||||
|
|
Loading…
Reference in New Issue
Block a user