Skip to content

Commit f791792

Browse files
committed
2 parents efb42ff + 9329981 commit f791792

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

rest_framework/fields.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def set_value(dictionary, keys, value):
103103
dictionary[keys[-1]] = value
104104

105105

106-
class CreateOnlyDefault:
106+
class CreateOnlyDefault(object):
107107
"""
108108
This class may be used to provide default values that are only used
109109
for create operations, but that do not return any value for update
@@ -114,7 +114,7 @@ def __init__(self, default):
114114

115115
def set_context(self, serializer_field):
116116
self.is_update = serializer_field.parent.instance is not None
117-
if callable(self.default) and hasattr(self.default, 'set_context'):
117+
if callable(self.default) and hasattr(self.default, 'set_context') and not self.is_update:
118118
self.default.set_context(serializer_field)
119119

120120
def __call__(self):
@@ -130,7 +130,7 @@ def __repr__(self):
130130
)
131131

132132

133-
class CurrentUserDefault:
133+
class CurrentUserDefault(object):
134134
def set_context(self, serializer_field):
135135
self.user = serializer_field.context['request'].user
136136

0 commit comments

Comments
 (0)