django-rest-framework/api-guide/settings.html
2013-11-17 18:26:41 +00:00

469 lines
29 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>Django REST framework - Settings</title>
<link href="http://django-rest-framework.org/img/favicon.ico" rel="icon" type="image/x-icon">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Django, API, REST, Settings, API Reference">
<meta name="author" content="Tom Christie">
<!-- Le styles -->
<link href="http://django-rest-framework.org/css/prettify.css" rel="stylesheet">
<link href="http://django-rest-framework.org/css/bootstrap.css" rel="stylesheet">
<link href="http://django-rest-framework.org/css/bootstrap-responsive.css" rel="stylesheet">
<link href="http://django-rest-framework.org/css/default.css" rel="stylesheet">
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-18852272-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body onload="prettyPrint()" class="settings-page">
<div class="wrapper">
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
<a class="repo-link btn btn-inverse btn-small " href="../topics/documenting-your-api.html">Next <i class="icon-arrow-right icon-white"></i></a>
<a class="repo-link btn btn-inverse btn-small " href="../api-guide/testing.html"><i class="icon-arrow-left icon-white"></i> Previous</a>
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="http://django-rest-framework.org">Django REST framework</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li><a href="http://django-rest-framework.org">Home</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="http://django-rest-framework.org/tutorial/quickstart.html">Quickstart</a></li>
<li><a href="http://django-rest-framework.org/tutorial/1-serialization.html">1 - Serialization</a></li>
<li><a href="http://django-rest-framework.org/tutorial/2-requests-and-responses.html">2 - Requests and responses</a></li>
<li><a href="http://django-rest-framework.org/tutorial/3-class-based-views.html">3 - Class based views</a></li>
<li><a href="http://django-rest-framework.org/tutorial/4-authentication-and-permissions.html">4 - Authentication and permissions</a></li>
<li><a href="http://django-rest-framework.org/tutorial/5-relationships-and-hyperlinked-apis.html">5 - Relationships and hyperlinked APIs</a></li>
<li><a href="http://django-rest-framework.org/tutorial/6-viewsets-and-routers.html">6 - Viewsets and routers</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">API Guide <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="http://django-rest-framework.org/api-guide/requests.html">Requests</a></li>
<li><a href="http://django-rest-framework.org/api-guide/responses.html">Responses</a></li>
<li><a href="http://django-rest-framework.org/api-guide/views.html">Views</a></li>
<li><a href="http://django-rest-framework.org/api-guide/generic-views.html">Generic views</a></li>
<li><a href="http://django-rest-framework.org/api-guide/viewsets.html">Viewsets</a></li>
<li><a href="http://django-rest-framework.org/api-guide/routers.html">Routers</a></li>
<li><a href="http://django-rest-framework.org/api-guide/parsers.html">Parsers</a></li>
<li><a href="http://django-rest-framework.org/api-guide/renderers.html">Renderers</a></li>
<li><a href="http://django-rest-framework.org/api-guide/serializers.html">Serializers</a></li>
<li><a href="http://django-rest-framework.org/api-guide/fields.html">Serializer fields</a></li>
<li><a href="http://django-rest-framework.org/api-guide/relations.html">Serializer relations</a></li>
<li><a href="http://django-rest-framework.org/api-guide/authentication.html">Authentication</a></li>
<li><a href="http://django-rest-framework.org/api-guide/permissions.html">Permissions</a></li>
<li><a href="http://django-rest-framework.org/api-guide/throttling.html">Throttling</a></li>
<li><a href="http://django-rest-framework.org/api-guide/filtering.html">Filtering</a></li>
<li><a href="http://django-rest-framework.org/api-guide/pagination.html">Pagination</a></li>
<li><a href="http://django-rest-framework.org/api-guide/content-negotiation.html">Content negotiation</a></li>
<li><a href="http://django-rest-framework.org/api-guide/format-suffixes.html">Format suffixes</a></li>
<li><a href="http://django-rest-framework.org/api-guide/reverse.html">Returning URLs</a></li>
<li><a href="http://django-rest-framework.org/api-guide/exceptions.html">Exceptions</a></li>
<li><a href="http://django-rest-framework.org/api-guide/status-codes.html">Status codes</a></li>
<li><a href="http://django-rest-framework.org/api-guide/testing.html">Testing</a></li>
<li><a href="http://django-rest-framework.org/api-guide/settings.html">Settings</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Topics <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="http://django-rest-framework.org/topics/documenting-your-api.html">Documenting your API</a></li>
<li><a href="http://django-rest-framework.org/topics/ajax-csrf-cors.html">AJAX, CSRF & CORS</a></li>
<li><a href="http://django-rest-framework.org/topics/browser-enhancements.html">Browser enhancements</a></li>
<li><a href="http://django-rest-framework.org/topics/browsable-api.html">The Browsable API</a></li>
<li><a href="http://django-rest-framework.org/topics/rest-hypermedia-hateoas.html">REST, Hypermedia & HATEOAS</a></li>
<li><a href="http://django-rest-framework.org/topics/rest-framework-2-announcement.html">2.0 Announcement</a></li>
<li><a href="http://django-rest-framework.org/topics/2.2-announcement.html">2.2 Announcement</a></li>
<li><a href="http://django-rest-framework.org/topics/2.3-announcement.html">2.3 Announcement</a></li>
<li><a href="http://django-rest-framework.org/topics/release-notes.html">Release Notes</a></li>
<li><a href="http://django-rest-framework.org/topics/credits.html">Credits</a></li>
</ul>
</li>
</ul>
<ul class="nav pull-right">
<!-- TODO
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Version: 2.0.0 <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Trunk</a></li>
<li><a href="#">2.0.0</a></li>
</ul>
</li>
-->
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="body-content">
<div class="container-fluid">
<!-- Search Modal -->
<div id="searchModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3 id="myModalLabel">Documentation search</h3>
</div>
<div class="modal-body">
<!-- Custom google search -->
<script>
(function() {
var cx = '015016005043623903336:rxraeohqk6w';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:search></gcse:search>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
<div class="row-fluid">
<div class="span3">
<!-- TODO
<p style="margin-top: -12px">
<a class="btn btn-mini btn-primary" style="width: 60px">&laquo; previous</a>
<a class="btn btn-mini btn-primary" style="float: right; margin-right: 8px; width: 60px;">next &raquo;</a>
</p>
-->
<div id="table-of-contents">
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
<li class="main"><a href="#settings">Settings</a></li>
<li><a href="#accessing-settings">Accessing settings</a></li>
<li class="main"><a href="#api-reference">API Reference</a></li>
<li><a href="#api-policy-settings">API policy settings</a></li>
<li><a href="#generic-view-settings">Generic view settings</a></li>
<li><a href="#authentication-settings">Authentication settings</a></li>
<li><a href="#test-settings">Test settings</a></li>
<li><a href="#browser-overrides">Browser overrides</a></li>
<li><a href="#date-and-time-formatting">Date and time formatting</a></li>
<li><a href="#view-names-and-descriptions">View names and descriptions</a></li>
<li><a href="#miscellaneous-settings">Miscellaneous settings</a></li>
<div>
<hr>
<p><strong>The team behind REST framework are launching a new API service.</strong></p>
<p>If you want to be first in line when we start issuing invitations, please sign up here:</p>
<!-- Begin MailChimp Signup Form -->
<link href="//cdn-images.mailchimp.com/embedcode/slim-081711.css" rel="stylesheet" type="text/css">
<style type="text/css">
#mc_embed_signup{background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; }
/* Add your own MailChimp form style overrides in your site stylesheet or in this style block.
We recommend moving this block and the preceding CSS link to the HEAD of your HTML file. */
</style>
<div id="mc_embed_signup" style="background: rgb(245, 245, 245)">
<form action="http://dabapps.us1.list-manage1.com/subscribe/post?u=cf73a9994eb5b8d8d461b5dfb&amp;id=cb6af8e8bd" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<!-- <label for="mce-EMAIL">Keep me posted!</label>
--> <input style="width: 90%" type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email address" required>
<div class="clear"><input class="btn btn-success" type="submit" value="Yes, keep me posted!" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
</form>
</div>
</style></div>
</ul>
<!--End mc_embed_signup-->
</div>
</div>
<div id="main-content" class="span9">
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/tree/master/rest_framework/settings.py"><span class="label label-info">settings.py</span></a></p>
<h1 id="settings">Settings</h1>
<blockquote>
<p>Namespaces are one honking great idea - let's do more of those!</p>
<p>&mdash; <a href="http://www.python.org/dev/peps/pep-0020/">The Zen of Python</a></p>
</blockquote>
<p>Configuration for REST framework is all namespaced inside a single Django setting, named <code>REST_FRAMEWORK</code>.</p>
<p>For example your project's <code>settings.py</code> file might include something like this:</p>
<pre class="prettyprint lang-py"><code>REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.YAMLRenderer',
),
'DEFAULT_PARSER_CLASSES': (
'rest_framework.parsers.YAMLParser',
)
}
</code></pre>
<h2 id="accessing-settings">Accessing settings</h2>
<p>If you need to access the values of REST framework's API settings in your project,
you should use the <code>api_settings</code> object. For example.</p>
<pre class="prettyprint lang-py"><code>from rest_framework.settings import api_settings
print api_settings.DEFAULT_AUTHENTICATION_CLASSES
</code></pre>
<p>The <code>api_settings</code> object will check for any user-defined settings, and otherwise fall back to the default values. Any setting that uses string import paths to refer to a class will automatically import and return the referenced class, instead of the string literal.</p>
<hr />
<h1 id="api-reference">API Reference</h1>
<h2 id="api-policy-settings">API policy settings</h2>
<p><em>The following settings control the basic API policies, and are applied to every <code>APIView</code> class based view, or <code>@api_view</code> function based view.</em></p>
<h4 id="default_renderer_classes">DEFAULT_RENDERER_CLASSES</h4>
<p>A list or tuple of renderer classes, that determines the default set of renderers that may be used when returning a <code>Response</code> object.</p>
<p>Default:</p>
<pre class="prettyprint lang-py"><code>(
'rest_framework.renderers.JSONRenderer',
'rest_framework.renderers.BrowsableAPIRenderer',
)
</code></pre>
<h4 id="default_parser_classes">DEFAULT_PARSER_CLASSES</h4>
<p>A list or tuple of parser classes, that determines the default set of parsers used when accessing the <code>request.DATA</code> property.</p>
<p>Default:</p>
<pre class="prettyprint lang-py"><code>(
'rest_framework.parsers.JSONParser',
'rest_framework.parsers.FormParser',
'rest_framework.parsers.MultiPartParser'
)
</code></pre>
<h4 id="default_authentication_classes">DEFAULT_AUTHENTICATION_CLASSES</h4>
<p>A list or tuple of authentication classes, that determines the default set of authenticators used when accessing the <code>request.user</code> or <code>request.auth</code> properties.</p>
<p>Default:</p>
<pre class="prettyprint lang-py"><code>(
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.BasicAuthentication'
)
</code></pre>
<h4 id="default_permission_classes">DEFAULT_PERMISSION_CLASSES</h4>
<p>A list or tuple of permission classes, that determines the default set of permissions checked at the start of a view.</p>
<p>Default:</p>
<pre class="prettyprint lang-py"><code>(
'rest_framework.permissions.AllowAny',
)
</code></pre>
<h4 id="default_throttle_classes">DEFAULT_THROTTLE_CLASSES</h4>
<p>A list or tuple of throttle classes, that determines the default set of throttles checked at the start of a view.</p>
<p>Default: <code>()</code></p>
<h4 id="default_content_negotiation_class">DEFAULT_CONTENT_NEGOTIATION_CLASS</h4>
<p>A content negotiation class, that determines how a renderer is selected for the response, given an incoming request.</p>
<p>Default: <code>'rest_framework.negotiation.DefaultContentNegotiation'</code></p>
<hr />
<h2 id="generic-view-settings">Generic view settings</h2>
<p><em>The following settings control the behavior of the generic class based views.</em></p>
<h4 id="default_model_serializer_class">DEFAULT_MODEL_SERIALIZER_CLASS</h4>
<p>A class that determines the default type of model serializer that should be used by a generic view if <code>model</code> is specified, but <code>serializer_class</code> is not provided.</p>
<p>Default: <code>'rest_framework.serializers.ModelSerializer'</code></p>
<h4 id="default_pagination_serializer_class">DEFAULT_PAGINATION_SERIALIZER_CLASS</h4>
<p>A class the determines the default serialization style for paginated responses.</p>
<p>Default: <code>rest_framework.pagination.PaginationSerializer</code></p>
<h4 id="default_filter_backends">DEFAULT_FILTER_BACKENDS</h4>
<p>A list of filter backend classes that should be used for generic filtering.
If set to <code>None</code> then generic filtering is disabled.</p>
<h4 id="paginate_by">PAGINATE_BY</h4>
<p>The default page size to use for pagination. If set to <code>None</code>, pagination is disabled by default.</p>
<p>Default: <code>None</code></p>
<h4 id="paginate_by_param">PAGINATE_BY_PARAM</h4>
<p>The name of a query parameter, which can be used by the client to override the default page size to use for pagination. If set to <code>None</code>, clients may not override the default page size.</p>
<p>For example, given the following settings:</p>
<pre class="prettyprint lang-py"><code>REST_FRAMEWORK = {
'PAGINATE_BY': 10,
'PAGINATE_BY_PARAM': 'page_size',
}
</code></pre>
<p>A client would be able to modify the pagination size by using the <code>page_size</code> query parameter. For example:</p>
<pre class="prettyprint lang-py"><code>GET http://example.com/api/accounts?page_size=25
</code></pre>
<p>Default: <code>None</code></p>
<h4 id="max_paginate_by">MAX_PAGINATE_BY</h4>
<p>The maximum page size to allow when the page size is specified by the client. If set to <code>None</code>, then no maximum limit is applied.</p>
<p>For example, given the following settings:</p>
<pre class="prettyprint lang-py"><code>REST_FRAMEWORK = {
'PAGINATE_BY': 10,
'PAGINATE_BY_PARAM': 'page_size',
'MAX_PAGINATE_BY': 100
}
</code></pre>
<p>A client request like the following would return a paginated list of up to 100 items.</p>
<pre class="prettyprint lang-py"><code>GET http://example.com/api/accounts?page_size=999
</code></pre>
<p>Default: <code>None</code></p>
<hr />
<h2 id="authentication-settings">Authentication settings</h2>
<p><em>The following settings control the behavior of unauthenticated requests.</em></p>
<h4 id="unauthenticated_user">UNAUTHENTICATED_USER</h4>
<p>The class that should be used to initialize <code>request.user</code> for unauthenticated requests.</p>
<p>Default: <code>django.contrib.auth.models.AnonymousUser</code></p>
<h4 id="unauthenticated_token">UNAUTHENTICATED_TOKEN</h4>
<p>The class that should be used to initialize <code>request.auth</code> for unauthenticated requests.</p>
<p>Default: <code>None</code></p>
<hr />
<h2 id="test-settings">Test settings</h2>
<p><em>The following settings control the behavior of APIRequestFactory and APIClient</em></p>
<h4 id="test_request_default_format">TEST_REQUEST_DEFAULT_FORMAT</h4>
<p>The default format that should be used when making test requests.</p>
<p>This should match up with the format of one of the renderer classes in the <code>TEST_REQUEST_RENDERER_CLASSES</code> setting.</p>
<p>Default: <code>'multipart'</code></p>
<h4 id="test_request_renderer_classes">TEST_REQUEST_RENDERER_CLASSES</h4>
<p>The renderer classes that are supported when building test requests.</p>
<p>The format of any of these renderer classes may be used when constructing a test request, for example: <code>client.post('/users', {'username': 'jamie'}, format='json')</code></p>
<p>Default:</p>
<pre class="prettyprint lang-py"><code>(
'rest_framework.renderers.MultiPartRenderer',
'rest_framework.renderers.JSONRenderer'
)
</code></pre>
<hr />
<h2 id="browser-overrides">Browser overrides</h2>
<p><em>The following settings provide URL or form-based overrides of the default browser behavior.</em></p>
<h4 id="form_method_override">FORM_METHOD_OVERRIDE</h4>
<p>The name of a form field that may be used to override the HTTP method of the form.</p>
<p>If the value of this setting is <code>None</code> then form method overloading will be disabled.</p>
<p>Default: <code>'_method'</code></p>
<h4 id="form_content_override">FORM_CONTENT_OVERRIDE</h4>
<p>The name of a form field that may be used to override the content of the form payload. Must be used together with <code>FORM_CONTENTTYPE_OVERRIDE</code>.</p>
<p>If either setting is <code>None</code> then form content overloading will be disabled.</p>
<p>Default: <code>'_content'</code></p>
<h4 id="form_contenttype_override">FORM_CONTENTTYPE_OVERRIDE</h4>
<p>The name of a form field that may be used to override the content type of the form payload. Must be used together with <code>FORM_CONTENT_OVERRIDE</code>.</p>
<p>If either setting is <code>None</code> then form content overloading will be disabled.</p>
<p>Default: <code>'_content_type'</code></p>
<h4 id="url_accept_override">URL_ACCEPT_OVERRIDE</h4>
<p>The name of a URL parameter that may be used to override the HTTP <code>Accept</code> header.</p>
<p>If the value of this setting is <code>None</code> then URL accept overloading will be disabled.</p>
<p>Default: <code>'accept'</code></p>
<h4 id="url_format_override">URL_FORMAT_OVERRIDE</h4>
<p>The name of a URL parameter that may be used to override the default <code>Accept</code> header based content negotiation.</p>
<p>Default: <code>'format'</code></p>
<hr />
<h2 id="date-and-time-formatting">Date and time formatting</h2>
<p><em>The following settings are used to control how date and time representations may be parsed and rendered.</em></p>
<h4 id="datetime_format">DATETIME_FORMAT</h4>
<p>A format string that should be used by default for rendering the output of <code>DateTimeField</code> serializer fields. If <code>None</code>, then <code>DateTimeField</code> serializer fields will return Python <code>datetime</code> objects, and the datetime encoding will be determined by the renderer.</p>
<p>May be any of <code>None</code>, <code>'iso-8601'</code> or a Python <a href="http://docs.python.org/2/library/time.html#time.strftime">strftime format</a> string.</p>
<p>Default: <code>None</code></p>
<h4 id="datetime_input_formats">DATETIME_INPUT_FORMATS</h4>
<p>A list of format strings that should be used by default for parsing inputs to <code>DateTimeField</code> serializer fields.</p>
<p>May be a list including the string <code>'iso-8601'</code> or Python <a href="http://docs.python.org/2/library/time.html#time.strftime">strftime format</a> strings.</p>
<p>Default: <code>['iso-8601']</code></p>
<h4 id="date_format">DATE_FORMAT</h4>
<p>A format string that should be used by default for rendering the output of <code>DateField</code> serializer fields. If <code>None</code>, then <code>DateField</code> serializer fields will return Python <code>date</code> objects, and the date encoding will be determined by the renderer.</p>
<p>May be any of <code>None</code>, <code>'iso-8601'</code> or a Python <a href="http://docs.python.org/2/library/time.html#time.strftime">strftime format</a> string.</p>
<p>Default: <code>None</code></p>
<h4 id="date_input_formats">DATE_INPUT_FORMATS</h4>
<p>A list of format strings that should be used by default for parsing inputs to <code>DateField</code> serializer fields.</p>
<p>May be a list including the string <code>'iso-8601'</code> or Python <a href="http://docs.python.org/2/library/time.html#time.strftime">strftime format</a> strings.</p>
<p>Default: <code>['iso-8601']</code></p>
<h4 id="time_format">TIME_FORMAT</h4>
<p>A format string that should be used by default for rendering the output of <code>TimeField</code> serializer fields. If <code>None</code>, then <code>TimeField</code> serializer fields will return Python <code>time</code> objects, and the time encoding will be determined by the renderer.</p>
<p>May be any of <code>None</code>, <code>'iso-8601'</code> or a Python <a href="http://docs.python.org/2/library/time.html#time.strftime">strftime format</a> string.</p>
<p>Default: <code>None</code></p>
<h4 id="time_input_formats">TIME_INPUT_FORMATS</h4>
<p>A list of format strings that should be used by default for parsing inputs to <code>TimeField</code> serializer fields.</p>
<p>May be a list including the string <code>'iso-8601'</code> or Python <a href="http://docs.python.org/2/library/time.html#time.strftime">strftime format</a> strings.</p>
<p>Default: <code>['iso-8601']</code></p>
<hr />
<h2 id="view-names-and-descriptions">View names and descriptions</h2>
<p><strong>The following settings are used to generate the view names and descriptions, as used in responses to <code>OPTIONS</code> requests, and as used in the browsable API.</strong></p>
<h4 id="view_name_function">VIEW_NAME_FUNCTION</h4>
<p>A string representing the function that should be used when generating view names.</p>
<p>This should be a function with the following signature:</p>
<pre class="prettyprint lang-py"><code>view_name(cls, suffix=None)
</code></pre>
<ul>
<li><code>cls</code>: The view class. Typically the name function would inspect the name of the class when generating a descriptive name, by accessing <code>cls.__name__</code>.</li>
<li><code>suffix</code>: The optional suffix used when differentiating individual views in a viewset.</li>
</ul>
<p>Default: <code>'rest_framework.views.get_view_name'</code></p>
<h4 id="view_description_function">VIEW_DESCRIPTION_FUNCTION</h4>
<p>A string representing the function that should be used when generating view descriptions.</p>
<p>This setting can be changed to support markup styles other than the default markdown. For example, you can use it to support <code>rst</code> markup in your view docstrings being output in the browsable API.</p>
<p>This should be a function with the following signature:</p>
<pre class="prettyprint lang-py"><code>view_description(cls, html=False)
</code></pre>
<ul>
<li><code>cls</code>: The view class. Typically the description function would inspect the docstring of the class when generating a description, by accessing <code>cls.__doc__</code></li>
<li><code>html</code>: A boolean indicating if HTML output is required. <code>True</code> when used in the browsable API, and <code>False</code> when used in generating <code>OPTIONS</code> responses.</li>
</ul>
<p>Default: <code>'rest_framework.views.get_view_description'</code></p>
<hr />
<h2 id="miscellaneous-settings">Miscellaneous settings</h2>
<h4 id="exception_handler">EXCEPTION_HANDLER</h4>
<p>A string representing the function that should be used when returning a response for any given exception. If the function returns <code>None</code>, a 500 error will be raised.</p>
<p>This setting can be changed to support error responses other than the default <code>{"detail": "Failure..."}</code> responses. For example, you can use it to provide API responses like <code>{"errors": [{"message": "Failure...", "code": ""} ...]}</code>.</p>
<p>This should be a function with the following signature:</p>
<pre class="prettyprint lang-py"><code>exception_handler(exc)
</code></pre>
<ul>
<li><code>exc</code>: The exception.</li>
</ul>
<p>Default: <code>'rest_framework.views.exception_handler'</code></p>
<h4 id="format_suffix_kwarg">FORMAT_SUFFIX_KWARG</h4>
<p>The name of a parameter in the URL conf that may be used to provide a format suffix.</p>
<p>Default: <code>'format'</code></p>
</div><!--/span-->
</div><!--/row-->
</div><!--/.fluid-container-->
</div><!--/.body content-->
<div id="push"></div>
</div><!--/.wrapper -->
<footer class="span12">
<p>Sponsored by <a href="http://dabapps.com/">DabApps</a>.</a></p>
</footer>
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="http://django-rest-framework.org/js/jquery-1.8.1-min.js"></script>
<script src="http://django-rest-framework.org/js/prettify-1.0.js"></script>
<script src="http://django-rest-framework.org/js/bootstrap-2.1.1-min.js"></script>
<script>
//$('.side-nav').scrollspy()
var shiftWindow = function() { scrollBy(0, -50) };
if (location.hash) shiftWindow();
window.addEventListener("hashchange", shiftWindow);
$('.dropdown-menu').on('click touchstart', function(event) {
event.stopPropagation();
});
// Dynamically force sidenav to no higher than browser window
$('.side-nav').css('max-height', window.innerHeight - 130);
$(function(){
$(window).resize(function(){
$('.side-nav').css('max-height', window.innerHeight - 130);
});
});
</script>
</body></html>