Skip to content

Commit 4f25208

Browse files
committed
Merge pull request encode#3981 from Inventorum/inventorum
[2.4] Fixes for Django 1.9
2 parents 8685ea5 + 79d7021 commit 4f25208

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ env:
2222
- TOX_ENV=py2.6-django1.4
2323

2424
install:
25-
- "pip install tox --download-cache $HOME/.pip-cache"
25+
# Virtualenv < 14 is required to keep the Python 3.2 builds running.
26+
- "pip install tox 'virtualenv<14' --download-cache $HOME/.pip-cache"
2627

2728
script:
2829
- tox -e $TOX_ENV

rest_framework/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99

1010
__title__ = 'Django REST framework'
11-
__version__ = '2.4.8'
11+
__version__ = '2.4.9'
1212
__author__ = 'Tom Christie'
1313
__license__ = 'BSD 2-Clause'
1414
__copyright__ = 'Copyright 2011-2014 Tom Christie'

rest_framework/compat.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@
7373
from collections import UserDict
7474
from collections import MutableMapping as DictMixin
7575

76+
# http responses move in Python 3
77+
try:
78+
from httplib import responses
79+
except ImportError:
80+
from http.client import responses
81+
7682
# Try to import PIL in either of the two ways it can end up installed.
7783
try:
7884
from PIL import Image

rest_framework/response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"""
77
from __future__ import unicode_literals
88
import django
9-
from django.core.handlers.wsgi import STATUS_CODE_TEXT
109
from django.template.response import SimpleTemplateResponse
1110
from django.utils import six
11+
from rest_framework.compat import responses
1212

1313

1414
class Response(SimpleTemplateResponse):
@@ -81,7 +81,7 @@ def status_text(self):
8181
"""
8282
# TODO: Deprecate and use a template tag instead
8383
# TODO: Status code text for RFC 6585 status codes
84-
return STATUS_CODE_TEXT.get(self.status_code, '')
84+
return responses.get(self.status_code, '')
8585

8686
def __getstate__(self):
8787
"""

rest_framework/serializers.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
import datetime
1616
import inspect
1717
import types
18+
19+
import django
20+
1821
from decimal import Decimal
1922
from django.core.paginator import Page
2023
from django.db import models
@@ -1079,6 +1082,12 @@ def save_object(self, obj, **kwargs):
10791082
fk_field = obj._meta.get_field_by_name(accessor_name)[0].field.name
10801083
setattr(related, fk_field, obj)
10811084
self.save_object(related)
1085+
elif isinstance(related, list):
1086+
# Many to One/Many
1087+
if django.VERSION >= (1, 9):
1088+
getattr(obj, accessor_name).add(*related, bulk=False)
1089+
else:
1090+
getattr(obj, accessor_name).add(*related)
10821091
else:
10831092
# Reverse FK or reverse one-one
10841093
setattr(obj, accessor_name, related)

0 commit comments

Comments
 (0)