Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
c7070346
Commit
c7070346
authored
Sep 06, 2012
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more settings to settings.py
parent
74c50b95
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
14 deletions
+18
-14
djangorestframework/settings.py
+17
-7
docs/api-guide/settings.md
+1
-7
No files found.
djangorestframework/settings.py
View file @
c7070346
...
...
@@ -29,6 +29,12 @@ DEFAULTS = {
'djangorestframework.parsers.JSONParser'
,
'djangorestframework.parsers.FormParser'
),
'DEFAULT_AUTHENTICATION'
:
(
'djangorestframework.authentication.SessionAuthentication'
,
'djangorestframework.authentication.UserBasicAuthentication'
),
'DEFAULT_PERMISSIONS'
:
(),
'DEFAULT_THROTTLES'
:
(),
'UNAUTHENTICATED_USER'
:
'django.contrib.auth.models.AnonymousUser'
,
'UNAUTHENTICATED_TOKEN'
:
None
}
...
...
@@ -40,6 +46,10 @@ if yaml:
# List of settings that may be in string import notation.
IMPORT_STRINGS
=
(
'DEFAULT_RENDERERS'
,
'DEFAULT_PARSERS'
,
'DEFAULT_AUTHENTICATION'
,
'DEFAULT_PERMISSIONS'
,
'DEFAULT_THROTTLES'
,
'UNAUTHENTICATED_USER'
,
'UNAUTHENTICATED_TOKEN'
)
...
...
@@ -53,26 +63,26 @@ def perform_import(val, setting):
if
val
is
None
or
setting
not
in
IMPORT_STRINGS
:
return
val
try
:
if
isinstance
(
val
,
basestring
):
return
import_from_string
(
val
)
return
import_from_string
(
val
,
setting
)
elif
isinstance
(
val
,
(
list
,
tuple
)):
return
[
import_from_string
(
item
)
for
item
in
val
]
return
[
import_from_string
(
item
,
setting
)
for
item
in
val
]
return
val
except
:
msg
=
"Could not import '
%
s' for API setting '
%
s'"
%
(
val
,
setting
)
raise
ImportError
(
msg
)
def
import_from_string
(
val
):
def
import_from_string
(
val
,
setting
):
"""
Attempt to import a class from a string representation.
"""
try
:
# Nod to tastypie's use of importlib.
parts
=
val
.
split
(
'.'
)
module_path
,
class_name
=
'.'
.
join
(
parts
[:
-
1
]),
parts
[
-
1
]
module
=
importlib
.
import_module
(
module_path
)
return
getattr
(
module
,
class_name
)
except
:
msg
=
"Could not import '
%
s' for API setting '
%
s'"
%
(
val
,
setting
)
raise
ImportError
(
msg
)
class
APISettings
(
object
):
...
...
docs/api-guide/settings.md
View file @
c7070346
...
...
@@ -40,19 +40,13 @@ Default:
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`
:
Default:
(
'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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment