mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-10 19:56:59 +03:00
Merge pull request #3981 from Inventorum/inventorum
[2.4] Fixes for Django 1.9
This commit is contained in:
commit
4f252086df
|
@ -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
|
||||||
|
|
|
@ -8,7 +8,7 @@ ______ _____ _____ _____ __
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__title__ = 'Django REST framework'
|
__title__ = 'Django REST framework'
|
||||||
__version__ = '2.4.8'
|
__version__ = '2.4.9'
|
||||||
__author__ = 'Tom Christie'
|
__author__ = 'Tom Christie'
|
||||||
__license__ = 'BSD 2-Clause'
|
__license__ = 'BSD 2-Clause'
|
||||||
__copyright__ = 'Copyright 2011-2014 Tom Christie'
|
__copyright__ = 'Copyright 2011-2014 Tom Christie'
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -6,9 +6,9 @@ The appropriate renderer is called during Django's template response rendering.
|
||||||
"""
|
"""
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import django
|
import django
|
||||||
from django.core.handlers.wsgi import STATUS_CODE_TEXT
|
|
||||||
from django.template.response import SimpleTemplateResponse
|
from django.template.response import SimpleTemplateResponse
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
|
from rest_framework.compat import responses
|
||||||
|
|
||||||
|
|
||||||
class Response(SimpleTemplateResponse):
|
class Response(SimpleTemplateResponse):
|
||||||
|
@ -81,7 +81,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 STATUS_CODE_TEXT.get(self.status_code, '')
|
return responses.get(self.status_code, '')
|
||||||
|
|
||||||
def __getstate__(self):
|
def __getstate__(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -15,6 +15,9 @@ import copy
|
||||||
import datetime
|
import datetime
|
||||||
import inspect
|
import inspect
|
||||||
import types
|
import types
|
||||||
|
|
||||||
|
import django
|
||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from django.core.paginator import Page
|
from django.core.paginator import Page
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
@ -1079,6 +1082,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
|
||||||
|
if django.VERSION >= (1, 9):
|
||||||
|
getattr(obj, accessor_name).add(*related, bulk=False)
|
||||||
|
else:
|
||||||
|
getattr(obj, accessor_name).add(*related)
|
||||||
else:
|
else:
|
||||||
# Reverse FK or reverse one-one
|
# Reverse FK or reverse one-one
|
||||||
setattr(obj, accessor_name, related)
|
setattr(obj, accessor_name, related)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user