mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 09:36:49 +03:00
Fix serialization issue with Django 1.3
This commit is contained in:
parent
25cbff5fab
commit
4ebd701be7
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
8
tox.ini
8
tox.ini
|
@ -11,11 +11,11 @@ deps = https://github.com/django/django/zipball/master
|
|||
|
||||
[testenv:py2.7-django1.4]
|
||||
basepython = python2.7
|
||||
deps = django>=1.4.1
|
||||
deps = django==1.4.1
|
||||
|
||||
[testenv:py2.7-django1.3]
|
||||
basepython = python2.7
|
||||
deps = django>=1.3.2
|
||||
deps = django==1.3.3
|
||||
|
||||
[testenv:py2.6-django1.5]
|
||||
basepython = python2.6
|
||||
|
@ -23,8 +23,8 @@ deps = https://github.com/django/django/zipball/master
|
|||
|
||||
[testenv:py2.6-django1.4]
|
||||
basepython = python2.6
|
||||
deps = django>=1.4.1
|
||||
deps = django==1.4.1
|
||||
|
||||
[testenv:py2.6-django1.3]
|
||||
basepython = python2.6
|
||||
deps = django>=1.3.2
|
||||
deps = django==1.3.3
|
||||
|
|
Loading…
Reference in New Issue
Block a user