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
f7917928
Commit
f7917928
authored
Mar 04, 2015
by
Tom Christie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/tomchristie/django-rest-framework
parents
efb42ff7
93299813
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
rest_framework/fields.py
+3
-3
No files found.
rest_framework/fields.py
View file @
f7917928
...
...
@@ -103,7 +103,7 @@ def set_value(dictionary, keys, value):
dictionary
[
keys
[
-
1
]]
=
value
class
CreateOnlyDefault
:
class
CreateOnlyDefault
(
object
)
:
"""
This class may be used to provide default values that are only used
for create operations, but that do not return any value for update
...
...
@@ -114,7 +114,7 @@ class CreateOnlyDefault:
def
set_context
(
self
,
serializer_field
):
self
.
is_update
=
serializer_field
.
parent
.
instance
is
not
None
if
callable
(
self
.
default
)
and
hasattr
(
self
.
default
,
'set_context'
):
if
callable
(
self
.
default
)
and
hasattr
(
self
.
default
,
'set_context'
)
and
not
self
.
is_update
:
self
.
default
.
set_context
(
serializer_field
)
def
__call__
(
self
):
...
...
@@ -130,7 +130,7 @@ class CreateOnlyDefault:
)
class
CurrentUserDefault
:
class
CurrentUserDefault
(
object
)
:
def
set_context
(
self
,
serializer_field
):
self
.
user
=
serializer_field
.
context
[
'request'
]
.
user
...
...
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