aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/serializers.py
diff options
context:
space:
mode:
authorTom Christie2014-09-15 13:55:09 +0100
committerTom Christie2014-09-15 13:55:09 +0100
commitd196608d5af912057baba79ab13d05d876368ad2 (patch)
tree1ce4dd59acaad98d6f6e0910618e00d98193405c /rest_framework/serializers.py
parent0c15b97b331f7937cbc5d85f660c07b3c92917a0 (diff)
downloaddjango-rest-framework-d196608d5af912057baba79ab13d05d876368ad2.tar.bz2
Fix nested model serializer base class
Diffstat (limited to 'rest_framework/serializers.py')
-rw-r--r--rest_framework/serializers.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py
index ba8d475f..40d76897 100644
--- a/rest_framework/serializers.py
+++ b/rest_framework/serializers.py
@@ -368,6 +368,7 @@ class ModelSerializer(Serializer):
models.TimeField: TimeField,
models.URLField: URLField,
}
+ nested_class = None # We fill this in at the end of this module.
_options_class = ModelSerializerOptions
@@ -454,7 +455,7 @@ class ModelSerializer(Serializer):
Note that model_field will be `None` for reverse relationships.
"""
- class NestedModelSerializer(ModelSerializer):
+ class NestedModelSerializer(self.nested_class):
class Meta:
model = related_model
depth = self.opts.depth - 1
@@ -694,3 +695,7 @@ class HyperlinkedModelSerializer(ModelSerializer):
'app_label': model._meta.app_label,
'model_name': model._meta.object_name.lower()
}
+
+
+ModelSerializer.nested_class = ModelSerializer
+HyperlinkedModelSerializer.nested_class = HyperlinkedModelSerializer