Skip to main content
All REST Framework settings are namespaced under the REST_FRAMEWORK dictionary in your Django settings.
# settings.py
REST_FRAMEWORK = {
    'DEFAULT_RENDERER_CLASSES': [
        'rest_framework.renderers.JSONRenderer',
    ],
    'DEFAULT_PARSER_CLASSES': [
        'rest_framework.parsers.JSONParser',
    ],
}

API Policy Settings

Settings that control basic API policies applied to all views.

DEFAULT_RENDERER_CLASSES

DEFAULT_RENDERER_CLASSES
list
List of renderer classes for returning responses.Default:
[
    'rest_framework.renderers.JSONRenderer',
    'rest_framework.renderers.BrowsableAPIRenderer',
]

DEFAULT_PARSER_CLASSES

DEFAULT_PARSER_CLASSES
list
List of parser classes for parsing request data.Default:
[
    'rest_framework.parsers.JSONParser',
    'rest_framework.parsers.FormParser',
    'rest_framework.parsers.MultiPartParser'
]

DEFAULT_AUTHENTICATION_CLASSES

DEFAULT_AUTHENTICATION_CLASSES
list
List of authentication classes.Default:
[
    'rest_framework.authentication.SessionAuthentication',
    'rest_framework.authentication.BasicAuthentication'
]

DEFAULT_PERMISSION_CLASSES

DEFAULT_PERMISSION_CLASSES
list
List of permission classes. All classes must grant permission.Default:
[
    'rest_framework.permissions.AllowAny',
]

DEFAULT_THROTTLE_CLASSES

DEFAULT_THROTTLE_CLASSES
list
List of throttle classes.Default: []

DEFAULT_CONTENT_NEGOTIATION_CLASS

DEFAULT_CONTENT_NEGOTIATION_CLASS
str
Content negotiation class for selecting renderers.Default: 'rest_framework.negotiation.DefaultContentNegotiation'

DEFAULT_METADATA_CLASS

DEFAULT_METADATA_CLASS
str
Metadata class for OPTIONS requests.Default: 'rest_framework.metadata.SimpleMetadata'

DEFAULT_VERSIONING_CLASS

DEFAULT_VERSIONING_CLASS
str
Versioning class for API versioning.Default: None

DEFAULT_SCHEMA_CLASS

DEFAULT_SCHEMA_CLASS
str
Schema class for automatic schema generation.Default: 'rest_framework.schemas.openapi.AutoSchema'

Generic View Settings

Settings that control generic view behavior.

DEFAULT_PAGINATION_CLASS

DEFAULT_PAGINATION_CLASS
str
Default pagination class for list views.Default: None (pagination disabled)

DEFAULT_FILTER_BACKENDS

DEFAULT_FILTER_BACKENDS
list
List of filter backend classes.Default: []

Pagination Settings

PAGE_SIZE

PAGE_SIZE
int
Default page size for pagination.Default: None (pagination disabled)

Filtering Settings

SEARCH_PARAM

SEARCH_PARAM
str
Query parameter name for SearchFilter.Default: 'search'

ORDERING_PARAM

ORDERING_PARAM
str
Query parameter name for OrderingFilter.Default: 'ordering'

Versioning Settings

DEFAULT_VERSION

DEFAULT_VERSION
str
Default version when no version is specified.Default: None

ALLOWED_VERSIONS

ALLOWED_VERSIONS
list
Set of allowed API versions.Default: None (all versions allowed)

VERSION_PARAM

VERSION_PARAM
str
Parameter name for versioning.Default: 'version'

Authentication Settings

UNAUTHENTICATED_USER

UNAUTHENTICATED_USER
str
Class for request.user in unauthenticated requests.Default: 'django.contrib.auth.models.AnonymousUser'

UNAUTHENTICATED_TOKEN

UNAUTHENTICATED_TOKEN
str
Class for request.auth in unauthenticated requests.Default: None

View Settings

VIEW_NAME_FUNCTION

VIEW_NAME_FUNCTION
str
Function to generate view names.Default: 'rest_framework.views.get_view_name'

VIEW_DESCRIPTION_FUNCTION

VIEW_DESCRIPTION_FUNCTION
str
Function to generate view descriptions.Default: 'rest_framework.views.get_view_description'

Exception Handling Settings

EXCEPTION_HANDLER

EXCEPTION_HANDLER
str
Function to handle exceptions.Default: 'rest_framework.views.exception_handler'

NON_FIELD_ERRORS_KEY

NON_FIELD_ERRORS_KEY
str
Key for non-field errors in validation errors.Default: 'non_field_errors'

Testing Settings

TEST_REQUEST_DEFAULT_FORMAT

TEST_REQUEST_DEFAULT_FORMAT
str
Default format for test requests.Default: 'multipart'

TEST_REQUEST_RENDERER_CLASSES

TEST_REQUEST_RENDERER_CLASSES
list
Available renderer classes for test requests.Default:
[
    'rest_framework.renderers.MultiPartRenderer',
    'rest_framework.renderers.JSONRenderer'
]

URL_FORMAT_OVERRIDE

URL_FORMAT_OVERRIDE
str
Query parameter name for format override.Default: 'format'

FORMAT_SUFFIX_KWARG

FORMAT_SUFFIX_KWARG
str
URL keyword argument name for format suffix.Default: 'format'

URL_FIELD_NAME

URL_FIELD_NAME
str
Field name for URL fields in HyperlinkedModelSerializer.Default: 'url'

Format Settings

DATE_FORMAT

DATE_FORMAT
str
Output format for DateField serialization.Default: 'iso-8601' (ISO 8601 format)Use Python strftime format strings or the special value 'iso-8601'.

DATE_INPUT_FORMATS

DATE_INPUT_FORMATS
list
Input formats for DateField parsing.Default: ['iso-8601']

DATETIME_FORMAT

DATETIME_FORMAT
str
Output format for DateTimeField serialization.Default: 'iso-8601'

DATETIME_INPUT_FORMATS

DATETIME_INPUT_FORMATS
list
Input formats for DateTimeField parsing.Default: ['iso-8601']

TIME_FORMAT

TIME_FORMAT
str
Output format for TimeField serialization.Default: 'iso-8601'

TIME_INPUT_FORMATS

TIME_INPUT_FORMATS
list
Input formats for TimeField parsing.Default: ['iso-8601']

DURATION_FORMAT

DURATION_FORMAT
str
Output format for DurationField serialization.Default: 'django-duration' (Django’s duration string format)Possible values: 'django-duration', 'iso-8601'

Encoding Settings

UNICODE_JSON

UNICODE_JSON
bool
Render JSON with unicode characters instead of escaped sequences.Default: True

COMPACT_JSON

COMPACT_JSON
bool
Render compact JSON (no extra whitespace).Default: True

STRICT_JSON

STRICT_JSON
bool
Use strict JSON encoding (reject NaN and Infinity).Default: True

COERCE_DECIMAL_TO_STRING

COERCE_DECIMAL_TO_STRING
bool
Render Decimal values as strings instead of floats.Default: True

COERCE_BIGINT_TO_STRING

COERCE_BIGINT_TO_STRING
bool
Render large integers (>53 bits) as strings to prevent precision loss in JavaScript.Default: False

UPLOADED_FILES_USE_URL

UPLOADED_FILES_USE_URL
bool
Use URL representation for file fields instead of file name.Default: True

Browsable API Settings

HTML_SELECT_CUTOFF

HTML_SELECT_CUTOFF
int
Maximum number of items to display in select dropdowns in browsable API.Default: 1000

HTML_SELECT_CUTOFF_TEXT

HTML_SELECT_CUTOFF_TEXT
str
Text to display when select cutoff is reached.Default: "More than {count} items..."

Throttling Settings

DEFAULT_THROTTLE_RATES

DEFAULT_THROTTLE_RATES
dict
Default throttle rates for throttle classes.Default:
{
    'user': None,
    'anon': None,
}
Rates use the format 'number/period', e.g.:
  • '100/hour'
  • '1000/day'
  • '5/second'

NUM_PROXIES

NUM_PROXIES
int
Number of proxies in front of the API for throttling IP address detection.Default: None

Schema Settings

SCHEMA_COERCE_PATH_PK

SCHEMA_COERCE_PATH_PK
bool
Coerce path pk parameters to use {id} in schema generation.Default: True

SCHEMA_COERCE_METHOD_NAMES

SCHEMA_COERCE_METHOD_NAMES
dict
Mapping of viewset method names to schema method names.Default:
{
    'retrieve': 'read',
    'destroy': 'delete'
}

Accessing Settings

Access settings using the api_settings object:
from rest_framework.settings import api_settings

print(api_settings.DEFAULT_AUTHENTICATION_CLASSES)
print(api_settings.PAGE_SIZE)

Example Configuration

# settings.py
REST_FRAMEWORK = {
    # Renderers
    'DEFAULT_RENDERER_CLASSES': [
        'rest_framework.renderers.JSONRenderer',
    ],
    
    # Parsers
    'DEFAULT_PARSER_CLASSES': [
        'rest_framework.parsers.JSONParser',
    ],
    
    # Authentication
    'DEFAULT_AUTHENTICATION_CLASSES': [
        'rest_framework_simplejwt.authentication.JWTAuthentication',
    ],
    
    # Permissions
    'DEFAULT_PERMISSION_CLASSES': [
        'rest_framework.permissions.IsAuthenticated',
    ],
    
    # Pagination
    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
    'PAGE_SIZE': 100,
    
    # Filtering
    'DEFAULT_FILTER_BACKENDS': [
        'django_filters.rest_framework.DjangoFilterBackend',
        'rest_framework.filters.SearchFilter',
        'rest_framework.filters.OrderingFilter',
    ],
    
    # Throttling
    'DEFAULT_THROTTLE_CLASSES': [
        'rest_framework.throttling.AnonRateThrottle',
        'rest_framework.throttling.UserRateThrottle',
    ],
    'DEFAULT_THROTTLE_RATES': {
        'anon': '100/hour',
        'user': '1000/hour',
    },
    
    # Versioning
    'DEFAULT_VERSIONING_CLASS': 'rest_framework.versioning.NamespaceVersioning',
    'DEFAULT_VERSION': 'v1',
    'ALLOWED_VERSIONS': ['v1', 'v2'],
    
    # Schema
    'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.openapi.AutoSchema',
    
    # Date/Time formats
    'DATETIME_FORMAT': '%Y-%m-%d %H:%M:%S',
    'DATE_FORMAT': '%Y-%m-%d',
    
    # Exception handling
    'EXCEPTION_HANDLER': 'myapp.exceptions.custom_exception_handler',
    
    # Testing
    'TEST_REQUEST_DEFAULT_FORMAT': 'json',
}

Build docs developers (and LLMs) love