diff options
| author | Tom Christie | 2012-09-28 14:53:22 +0100 |
|---|---|---|
| committer | Tom Christie | 2012-09-28 14:53:22 +0100 |
| commit | 4ebd701be74fbb1f44f7763f7ab9e19f6483ac96 (patch) | |
| tree | 4de29106eda93918ec8f4a85d028432b9f0e0830 /rest_framework | |
| parent | 25cbff5fabf2f989c7eb7ec2b72602bce1ceadfe (diff) | |
| download | django-rest-framework-4ebd701be74fbb1f44f7763f7ab9e19f6483ac96.tar.bz2 | |
Fix serialization issue with Django 1.3
Diffstat (limited to 'rest_framework')
| -rw-r--r-- | rest_framework/compat.py | 8 | ||||
| -rw-r--r-- | rest_framework/serializers.py | 3 |
2 files changed, 10 insertions, 1 deletions
diff --git a/rest_framework/compat.py b/rest_framework/compat.py index 5fc6c686..7664c400 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -10,6 +10,14 @@ except ImportError: import StringIO +def get_concrete_model(model_cls): + try: + return model_cls._meta.concrete_model + except AttributeError: + # 1.3 does not include concrete model + return model_cls + + # First implementation of Django class-based views did not include head method # in base View class - https://code.djangoproject.com/ticket/15668 if django.VERSION >= (1, 4): diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index 986d4225..bdb0f10a 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -4,6 +4,7 @@ import types from decimal import Decimal from django.core.serializers.base import DeserializedObject from django.utils.datastructures import SortedDict +from rest_framework.compat import get_concrete_model from rest_framework.fields import * @@ -299,7 +300,7 @@ class ModelSerializer(RelatedField, Serializer): else: cls = self.opts.model - opts = cls._meta.concrete_model._meta + opts = get_concrete_model(cls)._meta pk_field = opts.pk while pk_field.rel: pk_field = pk_field.rel.to._meta.pk |
