Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" 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.YAMLRenderer', ) 'DEFAULT_PARSER_CLASSES': ( 'rest_framework.parsers.JSONParser', 'rest_framework.parsers.YAMLParser', ) }
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. """
# Base API policies 'DEFAULT_RENDERER_CLASSES': ( 'rest_framework.renderers.JSONRenderer', 'rest_framework.renderers.BrowsableAPIRenderer', ), 'DEFAULT_PARSER_CLASSES': ( 'rest_framework.parsers.JSONParser', 'rest_framework.parsers.FormParser', 'rest_framework.parsers.MultiPartParser' ), 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.SessionAuthentication', 'rest_framework.authentication.BasicAuthentication' ), 'DEFAULT_PERMISSION_CLASSES': ( 'rest_framework.permissions.AllowAny', ), 'DEFAULT_THROTTLE_CLASSES': ( ),
'DEFAULT_CONTENT_NEGOTIATION_CLASS': 'rest_framework.negotiation.DefaultContentNegotiation',
# Genric view behavior 'DEFAULT_MODEL_SERIALIZER_CLASS': 'rest_framework.serializers.ModelSerializer', 'DEFAULT_PAGINATION_SERIALIZER_CLASS': 'rest_framework.pagination.PaginationSerializer', 'DEFAULT_FILTER_BACKENDS': (),
# Throttling 'DEFAULT_THROTTLE_RATES': { 'user': None, 'anon': None, },
# Pagination 'PAGINATE_BY': None, 'PAGINATE_BY_PARAM': None,
# Authentication 'UNAUTHENTICATED_USER': 'django.contrib.auth.models.AnonymousUser', 'UNAUTHENTICATED_TOKEN': None,
# Browser enhancements 'FORM_METHOD_OVERRIDE': '_method', 'FORM_CONTENT_OVERRIDE': '_content', 'FORM_CONTENTTYPE_OVERRIDE': '_content_type', 'URL_ACCEPT_OVERRIDE': 'accept', 'URL_FORMAT_OVERRIDE': 'format',
'FORMAT_SUFFIX_KWARG': 'format',
# Input and output formats 'DATE_INPUT_FORMATS': ( ISO_8601, ), 'DATE_FORMAT': None,
'DATETIME_INPUT_FORMATS': ( ISO_8601, ), 'DATETIME_FORMAT': None,
'TIME_INPUT_FORMATS': ( ISO_8601, ), 'TIME_FORMAT': None,
# Pending deprecation 'FILTER_BACKEND': None, }
# List of settings that may be in string import notation. 'DEFAULT_RENDERER_CLASSES', 'DEFAULT_PARSER_CLASSES', 'DEFAULT_AUTHENTICATION_CLASSES', 'DEFAULT_PERMISSION_CLASSES', 'DEFAULT_THROTTLE_CLASSES', 'DEFAULT_CONTENT_NEGOTIATION_CLASS', 'DEFAULT_MODEL_SERIALIZER_CLASS', 'DEFAULT_PAGINATION_SERIALIZER_CLASS', 'DEFAULT_FILTER_BACKENDS', 'FILTER_BACKEND', 'UNAUTHENTICATED_USER', 'UNAUTHENTICATED_TOKEN', )
""" If the given setting is a string import notation, then perform the necessary import or imports. """ return val
""" Attempt to import a class from a string representation. """ # Nod to tastypie's use of importlib.
""" 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. """
# Check if present in user settings # Fall back to defaults
# Coerce import strings into classes
# Cache the result
# Make sure we can initialize the class val()
|