aboutsummaryrefslogtreecommitdiffstats
path: root/docs/api-guide/settings.md
blob: fd35fbc64c12496a88d1d16bb95dc8750d048907 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Settings

Configuration for REST framework is all namespaced inside the `API_SETTINGS` setting.

For example your project's `settings.py` file might look like this:

    API_SETTINGS = {
        'DEFAULT_RENDERERS': (
            'djangorestframework.renderers.YAMLRenderer',
        )
        'DEFAULT_PARSERS': (
            'djangorestframework.parsers.YAMLParser',
        )
    }

## DEFAULT_RENDERERS

A list or tuple of renderer classes, that determines the default set of renderers that may be used when returning a `Response` object.

Default:

    (
        'djangorestframework.renderers.JSONRenderer',
        'djangorestframework.renderers.DocumentingHTMLRenderer'
        'djangorestframework.renderers.TemplateHTMLRenderer'
    )

## DEFAULT_PARSERS

A list or tuple of parser classes, that determines the default set of parsers used when accessing the `request.DATA` property.

Default:

    (
        'djangorestframework.parsers.JSONParser',
        'djangorestframework.parsers.FormParser'
    )

## DEFAULT_AUTHENTICATION

A list or tuple of authentication classes, that determines the default set of authenticators used when accessing the `request.user` or `request.auth` properties.

Default if `DEBUG` is `True`:

    (
        'djangorestframework.authentication.SessionAuthentication',
        'djangorestframework.authentication.UserBasicAuthentication'
    )

Default if `DEBUG` is `False`:

    (
        'djangorestframework.authentication.SessionAuthentication',
    )

## DEFAULT_PERMISSIONS

A list or tuple of permission classes, that determines the default set of permissions checked at the start of a view.

Default: `()`

## DEFAULT_THROTTLES

A list or tuple of throttle classes, that determines the default set of throttles checked at the start of a view.

Default: `()`

## DEFAULT_MODEL_SERIALIZER

Default: `djangorestframework.serializers.ModelSerializer`

## DEFAULT_PAGINATION_SERIALIZER

Default: `djangorestframework.pagination.PaginationSerializer`

## FORMAT_SUFFIX_KWARG

Default: `'format'`

## UNAUTHENTICATED_USER

The class that should be used to initialize `request.user` for unauthenticated requests.

Default: `django.contrib.auth.models.AnonymousUser`

## UNAUTHENTICATED_TOKEN

The class that should be used to initialize `request.auth` for unauthenticated requests.

Default: `None`

## FORM_METHOD_OVERRIDE

The name of a form field that may be used to override the HTTP method of the form.

If the value of this setting is `None` then form method overloading will be disabled.

Default: `'_method'`

## FORM_CONTENT_OVERRIDE

The name of a form field that may be used to override the content of the form payload.  Must be used together with `FORM_CONTENTTYPE_OVERRIDE`.

If either setting is `None` then form content overloading will be disabled.

Default: `'_content'`

## FORM_CONTENTTYPE_OVERRIDE

The name of a form field that may be used to override the content type of the form payload.  Must be used together with `FORM_CONTENT_OVERRIDE`.

If either setting is `None` then form content overloading will be disabled.

Default: `'_content_type'`

## URL_ACCEPT_OVERRIDE

The name of a URL parameter that may be used to override the HTTP `Accept` header.

If the value of this setting is `None` then URL accept overloading will be disabled.

Default: `'_accept'`