Skip to content

Commit 4ebd701

Browse files
committed
Fix serialization issue with Django 1.3
1 parent 25cbff5 commit 4ebd701

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

Diff for: rest_framework/compat.py

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
import StringIO
1111

1212

13+
def get_concrete_model(model_cls):
14+
try:
15+
return model_cls._meta.concrete_model
16+
except AttributeError:
17+
# 1.3 does not include concrete model
18+
return model_cls
19+
20+
1321
# First implementation of Django class-based views did not include head method
1422
# in base View class - https://code.djangoproject.com/ticket/15668
1523
if django.VERSION >= (1, 4):

Diff for: rest_framework/serializers.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from decimal import Decimal
55
from django.core.serializers.base import DeserializedObject
66
from django.utils.datastructures import SortedDict
7+
from rest_framework.compat import get_concrete_model
78
from rest_framework.fields import *
89

910

@@ -299,7 +300,7 @@ def default_fields(self, serialize, obj=None, data=None, nested=False):
299300
else:
300301
cls = self.opts.model
301302

302-
opts = cls._meta.concrete_model._meta
303+
opts = get_concrete_model(cls)._meta
303304
pk_field = opts.pk
304305
while pk_field.rel:
305306
pk_field = pk_field.rel.to._meta.pk

Diff for: tox.ini

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ deps = https://github.com/django/django/zipball/master
1111

1212
[testenv:py2.7-django1.4]
1313
basepython = python2.7
14-
deps = django>=1.4.1
14+
deps = django==1.4.1
1515

1616
[testenv:py2.7-django1.3]
1717
basepython = python2.7
18-
deps = django>=1.3.2
18+
deps = django==1.3.3
1919

2020
[testenv:py2.6-django1.5]
2121
basepython = python2.6
2222
deps = https://github.com/django/django/zipball/master
2323

2424
[testenv:py2.6-django1.4]
2525
basepython = python2.6
26-
deps = django>=1.4.1
26+
deps = django==1.4.1
2727

2828
[testenv:py2.6-django1.3]
2929
basepython = python2.6
30-
deps = django>=1.3.2
30+
deps = django==1.3.3

0 commit comments

Comments
 (0)