aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/serializers.py
diff options
context:
space:
mode:
authorTom Christie2013-03-13 12:48:27 +0000
committerTom Christie2013-03-13 12:48:27 +0000
commit76bf8db83aada25b76be9389b538ec3f3b99c6ac (patch)
tree3f85911664daeebf38275a6e0417490c78ffb145 /rest_framework/serializers.py
parent73ab7dc3f18c43d7bfb0c6f7581784d398cb36cf (diff)
parent0cf94cbd8b88de5da65f940351da2c2701ed877d (diff)
downloaddjango-rest-framework-76bf8db83aada25b76be9389b538ec3f3b99c6ac.tar.bz2
Merge branch 'master' of https://github.com/tomchristie/django-rest-framework
Diffstat (limited to 'rest_framework/serializers.py')
-rw-r--r--rest_framework/serializers.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py
index 2ae7c215..cd2bb8f1 100644
--- a/rest_framework/serializers.py
+++ b/rest_framework/serializers.py
@@ -456,8 +456,11 @@ class ModelSerializer(Serializer):
"Serializer class '%s' is missing 'model' Meta option" % self.__class__.__name__
opts = get_concrete_model(cls)._meta
pk_field = opts.pk
- # while pk_field.rel:
- # pk_field = pk_field.rel.to._meta.pk
+
+ # If model is a child via multitable inheritance, use parent's pk
+ while pk_field.rel and pk_field.rel.parent_link:
+ pk_field = pk_field.rel.to._meta.pk
+
fields = [pk_field]
fields += [field for field in opts.fields if field.serialize]
fields += [field for field in opts.many_to_many if field.serialize]