Update default settings to use lists instead of tuples (#6799)

* Update default settings from tuples to lists

* Add missing trailing commas

* Use single quotes for consistency

* Update settings lists in docs
This commit is contained in:
Ryan P Kilby 2019-07-15 03:54:46 -07:00 committed by Tom Christie
parent f0dbf0a264
commit b26db12813
2 changed files with 36 additions and 36 deletions

View File

@ -47,10 +47,10 @@ A list or tuple of renderer classes, that determines the default set of renderer
Default: Default:
( [
'rest_framework.renderers.JSONRenderer', 'rest_framework.renderers.JSONRenderer',
'rest_framework.renderers.BrowsableAPIRenderer', 'rest_framework.renderers.BrowsableAPIRenderer',
) ]
#### DEFAULT_PARSER_CLASSES #### DEFAULT_PARSER_CLASSES
@ -58,11 +58,11 @@ A list or tuple of parser classes, that determines the default set of parsers us
Default: Default:
( [
'rest_framework.parsers.JSONParser', 'rest_framework.parsers.JSONParser',
'rest_framework.parsers.FormParser', 'rest_framework.parsers.FormParser',
'rest_framework.parsers.MultiPartParser' 'rest_framework.parsers.MultiPartParser'
) ]
#### DEFAULT_AUTHENTICATION_CLASSES #### DEFAULT_AUTHENTICATION_CLASSES
@ -70,10 +70,10 @@ A list or tuple of authentication classes, that determines the default set of au
Default: Default:
( [
'rest_framework.authentication.SessionAuthentication', 'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.BasicAuthentication' 'rest_framework.authentication.BasicAuthentication'
) ]
#### DEFAULT_PERMISSION_CLASSES #### DEFAULT_PERMISSION_CLASSES
@ -81,15 +81,15 @@ A list or tuple of permission classes, that determines the default set of permis
Default: Default:
( [
'rest_framework.permissions.AllowAny', 'rest_framework.permissions.AllowAny',
) ]
#### DEFAULT_THROTTLE_CLASSES #### DEFAULT_THROTTLE_CLASSES
A list or tuple of throttle classes, that determines the default set of throttles checked at the start of a view. A list or tuple of throttle classes, that determines the default set of throttles checked at the start of a view.
Default: `()` Default: `[]`
#### DEFAULT_CONTENT_NEGOTIATION_CLASS #### DEFAULT_CONTENT_NEGOTIATION_CLASS
@ -205,10 +205,10 @@ The format of any of these renderer classes may be used when constructing a test
Default: Default:
( [
'rest_framework.renderers.MultiPartRenderer', 'rest_framework.renderers.MultiPartRenderer',
'rest_framework.renderers.JSONRenderer' 'rest_framework.renderers.JSONRenderer'
) ]
--- ---

View File

@ -3,15 +3,15 @@ Settings for REST framework are all namespaced in the REST_FRAMEWORK setting.
For example your project's `settings.py` file might look like this: For example your project's `settings.py` file might look like this:
REST_FRAMEWORK = { REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': ( 'DEFAULT_RENDERER_CLASSES': [
'rest_framework.renderers.JSONRenderer', 'rest_framework.renderers.JSONRenderer',
'rest_framework.renderers.TemplateHTMLRenderer', 'rest_framework.renderers.TemplateHTMLRenderer',
) ],
'DEFAULT_PARSER_CLASSES': ( 'DEFAULT_PARSER_CLASSES': [
'rest_framework.parsers.JSONParser', 'rest_framework.parsers.JSONParser',
'rest_framework.parsers.FormParser', 'rest_framework.parsers.FormParser',
'rest_framework.parsers.MultiPartParser' 'rest_framework.parsers.MultiPartParser',
) ],
} }
This module provides the `api_setting` object, that is used to access This module provides the `api_setting` object, that is used to access
@ -26,30 +26,30 @@ from rest_framework import ISO_8601
DEFAULTS = { DEFAULTS = {
# Base API policies # Base API policies
'DEFAULT_RENDERER_CLASSES': ( 'DEFAULT_RENDERER_CLASSES': [
'rest_framework.renderers.JSONRenderer', 'rest_framework.renderers.JSONRenderer',
'rest_framework.renderers.BrowsableAPIRenderer', 'rest_framework.renderers.BrowsableAPIRenderer',
), ],
'DEFAULT_PARSER_CLASSES': ( 'DEFAULT_PARSER_CLASSES': [
'rest_framework.parsers.JSONParser', 'rest_framework.parsers.JSONParser',
'rest_framework.parsers.FormParser', 'rest_framework.parsers.FormParser',
'rest_framework.parsers.MultiPartParser' 'rest_framework.parsers.MultiPartParser'
), ],
'DEFAULT_AUTHENTICATION_CLASSES': ( 'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.SessionAuthentication', 'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.BasicAuthentication' 'rest_framework.authentication.BasicAuthentication'
), ],
'DEFAULT_PERMISSION_CLASSES': ( 'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.AllowAny', 'rest_framework.permissions.AllowAny',
), ],
'DEFAULT_THROTTLE_CLASSES': (), 'DEFAULT_THROTTLE_CLASSES': [],
'DEFAULT_CONTENT_NEGOTIATION_CLASS': 'rest_framework.negotiation.DefaultContentNegotiation', 'DEFAULT_CONTENT_NEGOTIATION_CLASS': 'rest_framework.negotiation.DefaultContentNegotiation',
'DEFAULT_METADATA_CLASS': 'rest_framework.metadata.SimpleMetadata', 'DEFAULT_METADATA_CLASS': 'rest_framework.metadata.SimpleMetadata',
'DEFAULT_VERSIONING_CLASS': None, 'DEFAULT_VERSIONING_CLASS': None,
# Generic view behavior # Generic view behavior
'DEFAULT_PAGINATION_CLASS': None, 'DEFAULT_PAGINATION_CLASS': None,
'DEFAULT_FILTER_BACKENDS': (), 'DEFAULT_FILTER_BACKENDS': [],
# Schema # Schema
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.openapi.AutoSchema', 'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.openapi.AutoSchema',
@ -86,10 +86,10 @@ DEFAULTS = {
'NON_FIELD_ERRORS_KEY': 'non_field_errors', 'NON_FIELD_ERRORS_KEY': 'non_field_errors',
# Testing # Testing
'TEST_REQUEST_RENDERER_CLASSES': ( 'TEST_REQUEST_RENDERER_CLASSES': [
'rest_framework.renderers.MultiPartRenderer', 'rest_framework.renderers.MultiPartRenderer',
'rest_framework.renderers.JSONRenderer' 'rest_framework.renderers.JSONRenderer'
), ],
'TEST_REQUEST_DEFAULT_FORMAT': 'multipart', 'TEST_REQUEST_DEFAULT_FORMAT': 'multipart',
# Hyperlink settings # Hyperlink settings
@ -99,13 +99,13 @@ DEFAULTS = {
# Input and output formats # Input and output formats
'DATE_FORMAT': ISO_8601, 'DATE_FORMAT': ISO_8601,
'DATE_INPUT_FORMATS': (ISO_8601,), 'DATE_INPUT_FORMATS': [ISO_8601],
'DATETIME_FORMAT': ISO_8601, 'DATETIME_FORMAT': ISO_8601,
'DATETIME_INPUT_FORMATS': (ISO_8601,), 'DATETIME_INPUT_FORMATS': [ISO_8601],
'TIME_FORMAT': ISO_8601, 'TIME_FORMAT': ISO_8601,
'TIME_INPUT_FORMATS': (ISO_8601,), 'TIME_INPUT_FORMATS': [ISO_8601],
# Encoding # Encoding
'UNICODE_JSON': True, 'UNICODE_JSON': True,
@ -128,7 +128,7 @@ DEFAULTS = {
# List of settings that may be in string import notation. # List of settings that may be in string import notation.
IMPORT_STRINGS = ( IMPORT_STRINGS = [
'DEFAULT_RENDERER_CLASSES', 'DEFAULT_RENDERER_CLASSES',
'DEFAULT_PARSER_CLASSES', 'DEFAULT_PARSER_CLASSES',
'DEFAULT_AUTHENTICATION_CLASSES', 'DEFAULT_AUTHENTICATION_CLASSES',
@ -146,13 +146,13 @@ IMPORT_STRINGS = (
'UNAUTHENTICATED_TOKEN', 'UNAUTHENTICATED_TOKEN',
'VIEW_NAME_FUNCTION', 'VIEW_NAME_FUNCTION',
'VIEW_DESCRIPTION_FUNCTION' 'VIEW_DESCRIPTION_FUNCTION'
) ]
# List of settings that have been removed # List of settings that have been removed
REMOVED_SETTINGS = ( REMOVED_SETTINGS = [
"PAGINATE_BY", "PAGINATE_BY_PARAM", "MAX_PAGINATE_BY", 'PAGINATE_BY', 'PAGINATE_BY_PARAM', 'MAX_PAGINATE_BY',
) ]
def perform_import(val, setting_name): def perform_import(val, setting_name):