aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework
diff options
context:
space:
mode:
authorTom Christie2015-03-04 16:17:44 +0000
committerTom Christie2015-03-04 16:17:44 +0000
commitf7917928c080aa0b055cbfc588f61ec01f16771c (patch)
treebe4e7b435f1f236628afff969cb3a500884262c1 /rest_framework
parentefb42ff7d048d165b151e3b75553ef720dc49cd3 (diff)
parent932998134fa15ca955d2575349078b2de8ddf892 (diff)
downloaddjango-rest-framework-f7917928c080aa0b055cbfc588f61ec01f16771c.tar.bz2
Merge branch 'master' of https://github.com/tomchristie/django-rest-framework
Diffstat (limited to 'rest_framework')
-rw-r--r--rest_framework/fields.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/rest_framework/fields.py b/rest_framework/fields.py
index c327f11b..a80862e8 100644
--- a/rest_framework/fields.py
+++ b/rest_framework/fields.py
@@ -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