Skip to content

Commit e26fe43

Browse files
committed
Fixed comments
1 parent 044fefa commit e26fe43

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
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/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
@@ -8,7 +8,7 @@
88
import django
99
from django.template.response import SimpleTemplateResponse
1010
from django.utils import six
11-
import httplib
11+
from rest_framework.compat import responses
1212

1313
class Response(SimpleTemplateResponse):
1414
"""
@@ -80,7 +80,7 @@ def status_text(self):
8080
"""
8181
# TODO: Deprecate and use a template tag instead
8282
# TODO: Status code text for RFC 6585 status codes
83-
return httplib[self.status_code]
83+
return responses.get(self.status_code, '')
8484

8585
def __getstate__(self):
8686
"""

rest_framework/serializers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,12 +1079,12 @@ def save_object(self, obj, **kwargs):
10791079
fk_field = obj._meta.get_field_by_name(accessor_name)[0].field.name
10801080
setattr(related, fk_field, obj)
10811081
self.save_object(related)
1082+
elif isinstance(related, list):
1083+
# Many to One/Many
1084+
getattr(obj, accessor_name).add(*related, bulk=False)
10821085
else:
10831086
# Reverse FK or reverse one-one
1084-
try:
1085-
setattr(obj, accessor_name, related)
1086-
except ValueError:
1087-
getattr(obj, accessor_name).add(*related, bulk=False)
1087+
setattr(obj, accessor_name, related)
10881088
del(obj._related_data)
10891089

10901090

0 commit comments

Comments
 (0)