mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-04-28 21:13:43 +03:00
Fixed comments
This commit is contained in:
parent
044fefa420
commit
e26fe4356b
|
@ -22,7 +22,8 @@ env:
|
||||||
- TOX_ENV=py2.6-django1.4
|
- TOX_ENV=py2.6-django1.4
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- "pip install tox --download-cache $HOME/.pip-cache"
|
# Virtualenv < 14 is required to keep the Python 3.2 builds running.
|
||||||
|
- "pip install tox 'virtualenv<14' --download-cache $HOME/.pip-cache"
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- tox -e $TOX_ENV
|
- tox -e $TOX_ENV
|
||||||
|
|
|
@ -73,6 +73,12 @@ except ImportError:
|
||||||
from collections import UserDict
|
from collections import UserDict
|
||||||
from collections import MutableMapping as DictMixin
|
from collections import MutableMapping as DictMixin
|
||||||
|
|
||||||
|
# http responses move in Python 3
|
||||||
|
try:
|
||||||
|
from httplib import responses
|
||||||
|
except ImportError:
|
||||||
|
from http.client import responses
|
||||||
|
|
||||||
# Try to import PIL in either of the two ways it can end up installed.
|
# Try to import PIL in either of the two ways it can end up installed.
|
||||||
try:
|
try:
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
|
@ -8,7 +8,7 @@ from __future__ import unicode_literals
|
||||||
import django
|
import django
|
||||||
from django.template.response import SimpleTemplateResponse
|
from django.template.response import SimpleTemplateResponse
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
import httplib
|
from rest_framework.compat import responses
|
||||||
|
|
||||||
class Response(SimpleTemplateResponse):
|
class Response(SimpleTemplateResponse):
|
||||||
"""
|
"""
|
||||||
|
@ -80,7 +80,7 @@ class Response(SimpleTemplateResponse):
|
||||||
"""
|
"""
|
||||||
# TODO: Deprecate and use a template tag instead
|
# TODO: Deprecate and use a template tag instead
|
||||||
# TODO: Status code text for RFC 6585 status codes
|
# TODO: Status code text for RFC 6585 status codes
|
||||||
return httplib[self.status_code]
|
return responses.get(self.status_code, '')
|
||||||
|
|
||||||
def __getstate__(self):
|
def __getstate__(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1079,12 +1079,12 @@ class ModelSerializer(Serializer):
|
||||||
fk_field = obj._meta.get_field_by_name(accessor_name)[0].field.name
|
fk_field = obj._meta.get_field_by_name(accessor_name)[0].field.name
|
||||||
setattr(related, fk_field, obj)
|
setattr(related, fk_field, obj)
|
||||||
self.save_object(related)
|
self.save_object(related)
|
||||||
|
elif isinstance(related, list):
|
||||||
|
# Many to One/Many
|
||||||
|
getattr(obj, accessor_name).add(*related, bulk=False)
|
||||||
else:
|
else:
|
||||||
# Reverse FK or reverse one-one
|
# Reverse FK or reverse one-one
|
||||||
try:
|
|
||||||
setattr(obj, accessor_name, related)
|
setattr(obj, accessor_name, related)
|
||||||
except ValueError:
|
|
||||||
getattr(obj, accessor_name).add(*related, bulk=False)
|
|
||||||
del(obj._related_data)
|
del(obj._related_data)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user