aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/fields.py
diff options
context:
space:
mode:
authorTom Christie2015-03-02 08:18:14 +0000
committerTom Christie2015-03-02 08:18:14 +0000
commit5aa204e94f3173e8bc20439033a5d613625b1311 (patch)
tree4d6c766f2e49dea2d6fbe49e242e60a2759828f3 /rest_framework/fields.py
parent33c4278ec8964a0ed5c447d08bc45c4da2bbd7ec (diff)
parentb582d52afbad81c56edad8ea3b6d2ac2d352b87e (diff)
downloaddjango-rest-framework-5aa204e94f3173e8bc20439033a5d613625b1311.tar.bz2
Merge pull request #2619 from kwood/master
Updated CreateOnlyDefault to call set_context on its default
Diffstat (limited to 'rest_framework/fields.py')
-rw-r--r--rest_framework/fields.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/rest_framework/fields.py b/rest_framework/fields.py
index 13301f31..c327f11b 100644
--- a/rest_framework/fields.py
+++ b/rest_framework/fields.py
@@ -114,6 +114,8 @@ 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'):
+ self.default.set_context(serializer_field)
def __call__(self):
if self.is_update: