rest_framework.settings

Settings for REST framework are all namespaced in the REST_FRAMEWORK setting. For example your project’s settings.py file might look like this:

REST_FRAMEWORK = {
‘DEFAULT_RENDERER_CLASSES’: (
‘rest_framework.renderers.JSONRenderer’, ‘rest_framework.renderers.TemplateHTMLRenderer’,

) ‘DEFAULT_PARSER_CLASSES’: (

’rest_framework.parsers.JSONParser’, ‘rest_framework.parsers.FormParser’, ‘rest_framework.parsers.MultiPartParser’

)

}

This module provides the api_setting object, that is used to access REST framework settings, checking for user settings first, then falling back to the defaults.

Module Contents

DEFAULTS
IMPORT_STRINGS = ['DEFAULT_RENDERER_CLASSES', 'DEFAULT_PARSER_CLASSES', 'DEFAULT_AUTHENTICATION_CLASSES', 'DEFAULT_PERMISSION_CLASSES', 'DEFAULT_THROTTLE_CLASSES', 'DEFAULT_CONTENT_NEGOTIATION_CLASS', 'DEFAULT_METADATA_CLASS', 'DEFAULT_VERSIONING_CLASS', 'DEFAULT_PAGINATION_CLASS', 'DEFAULT_FILTER_BACKENDS', 'DEFAULT_SCHEMA_CLASS', 'EXCEPTION_HANDLER', 'TEST_REQUEST_RENDERER_CLASSES', 'UNAUTHENTICATED_USER', 'UNAUTHENTICATED_TOKEN', 'VIEW_NAME_FUNCTION', 'VIEW_DESCRIPTION_FUNCTION']
REMOVED_SETTINGS = ['PAGINATE_BY', 'PAGINATE_BY_PARAM', 'MAX_PAGINATE_BY']
perform_import(val, setting_name)

If the given setting is a string import notation, then perform the necessary import or imports.

import_from_string(val, setting_name)

Attempt to import a class from a string representation.

class APISettings(user_settings=None, defaults=None, import_strings=None)

Bases:object

A settings object, that allows API settings to be accessed as properties. For example:

from rest_framework.settings import api_settings print(api_settings.DEFAULT_RENDERER_CLASSES)

Any setting with string import paths will be automatically resolved and return the class, rather than the string literal.

user_settings
__getattr__(self, attr)
__check_user_settings(self, user_settings)
reload(self)
api_settings
reload_api_settings(*args, **kwargs)