mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-06-10 00:23:32 +03:00
Drop six from compat. 1.4.2 is now the lowest supported version.
This commit is contained in:
parent
00c0dfc66f
commit
63d02dbea8
|
@ -27,7 +27,7 @@ There is a live example API for testing purposes, [available here][sandbox].
|
||||||
# Requirements
|
# Requirements
|
||||||
|
|
||||||
* Python (2.6.5+, 2.7, 3.2, 3.3)
|
* Python (2.6.5+, 2.7, 3.2, 3.3)
|
||||||
* Django (1.3, 1.4, 1.5, 1.6)
|
* Django (1.4.2+, 1.5, 1.6, 1.7)
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ Some reasons you might want to use REST framework:
|
||||||
REST framework requires the following:
|
REST framework requires the following:
|
||||||
|
|
||||||
* Python (2.6.5+, 2.7, 3.2, 3.3)
|
* Python (2.6.5+, 2.7, 3.2, 3.3)
|
||||||
* Django (1.3, 1.4, 1.5, 1.6)
|
* Django (1.4.2+, 1.5, 1.6, 1.7)
|
||||||
|
|
||||||
The following packages are optional:
|
The following packages are optional:
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
* Writable nested serializers.
|
|
||||||
* List/detail routes.
|
* List/detail routes.
|
||||||
* 1.3 Support dropped, install six for <=1.4.?.
|
* 1.3 Support dropped, install six for <=1.4.?.
|
||||||
* `allow_none` for char fields
|
* `allow_none` for char fields
|
||||||
|
|
|
@ -9,14 +9,9 @@ import django
|
||||||
import inspect
|
import inspect
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.utils import six
|
||||||
|
|
||||||
|
|
||||||
# Try to import six from Django, fallback to external `six` package.
|
|
||||||
try:
|
|
||||||
from django.utils import six
|
|
||||||
except ImportError:
|
|
||||||
import six
|
|
||||||
|
|
||||||
# Handle django.utils.encoding rename in 1.5 onwards.
|
# Handle django.utils.encoding rename in 1.5 onwards.
|
||||||
# smart_unicode -> smart_text
|
# smart_unicode -> smart_text
|
||||||
# force_unicode -> force_text
|
# force_unicode -> force_text
|
||||||
|
|
|
@ -7,7 +7,7 @@ based views, as well as the `@detail_route` and `@list_route` decorators, which
|
||||||
used to annotate methods on viewsets that should be included by routers.
|
used to annotate methods on viewsets that should be included by routers.
|
||||||
"""
|
"""
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from rest_framework.compat import six
|
from django.utils import six
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
import types
|
import types
|
||||||
import warnings
|
import warnings
|
||||||
|
|
|
@ -18,14 +18,14 @@ from django.conf import settings
|
||||||
from django.db.models.fields import BLANK_CHOICE_DASH
|
from django.db.models.fields import BLANK_CHOICE_DASH
|
||||||
from django.http import QueryDict
|
from django.http import QueryDict
|
||||||
from django.forms import widgets
|
from django.forms import widgets
|
||||||
from django.utils import timezone
|
from django.utils import six, timezone
|
||||||
from django.utils.encoding import is_protected_type
|
from django.utils.encoding import is_protected_type
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.utils.datastructures import SortedDict
|
from django.utils.datastructures import SortedDict
|
||||||
from django.utils.dateparse import parse_date, parse_datetime, parse_time
|
from django.utils.dateparse import parse_date, parse_datetime, parse_time
|
||||||
from rest_framework import ISO_8601
|
from rest_framework import ISO_8601
|
||||||
from rest_framework.compat import (
|
from rest_framework.compat import (
|
||||||
BytesIO, six, smart_text,
|
BytesIO, smart_text,
|
||||||
force_text, is_non_str_iterable
|
force_text, is_non_str_iterable
|
||||||
)
|
)
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework.settings import api_settings
|
||||||
|
|
|
@ -5,7 +5,8 @@ returned by list views.
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from rest_framework.compat import django_filters, six, guardian, get_model_name
|
from django.utils import six
|
||||||
|
from rest_framework.compat import django_filters, guardian, get_model_name
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework.settings import api_settings
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
import operator
|
import operator
|
||||||
|
|
|
@ -10,7 +10,8 @@ from django.core.files.uploadhandler import StopFutureHandlers
|
||||||
from django.http import QueryDict
|
from django.http import QueryDict
|
||||||
from django.http.multipartparser import MultiPartParser as DjangoMultiPartParser
|
from django.http.multipartparser import MultiPartParser as DjangoMultiPartParser
|
||||||
from django.http.multipartparser import MultiPartParserError, parse_header, ChunkIter
|
from django.http.multipartparser import MultiPartParserError, parse_header, ChunkIter
|
||||||
from rest_framework.compat import etree, six, yaml, force_text
|
from django.utils import six
|
||||||
|
from rest_framework.compat import etree, yaml, force_text
|
||||||
from rest_framework.exceptions import ParseError
|
from rest_framework.exceptions import ParseError
|
||||||
from rest_framework import renderers
|
from rest_framework import renderers
|
||||||
import json
|
import json
|
||||||
|
|
|
@ -15,11 +15,9 @@ from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.http.multipartparser import parse_header
|
from django.http.multipartparser import parse_header
|
||||||
from django.template import RequestContext, loader, Template
|
from django.template import RequestContext, loader, Template
|
||||||
from django.test.client import encode_multipart
|
from django.test.client import encode_multipart
|
||||||
|
from django.utils import six
|
||||||
from django.utils.xmlutils import SimplerXMLGenerator
|
from django.utils.xmlutils import SimplerXMLGenerator
|
||||||
from rest_framework.compat import StringIO
|
from rest_framework.compat import StringIO, smart_text, yaml
|
||||||
from rest_framework.compat import six
|
|
||||||
from rest_framework.compat import smart_text
|
|
||||||
from rest_framework.compat import yaml
|
|
||||||
from rest_framework.exceptions import ParseError
|
from rest_framework.exceptions import ParseError
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework.settings import api_settings
|
||||||
from rest_framework.request import is_form_media_type, override_method
|
from rest_framework.request import is_form_media_type, override_method
|
||||||
|
|
|
@ -8,7 +8,7 @@ from __future__ import unicode_literals
|
||||||
import django
|
import django
|
||||||
from django.core.handlers.wsgi import STATUS_CODE_TEXT
|
from django.core.handlers.wsgi import STATUS_CODE_TEXT
|
||||||
from django.template.response import SimpleTemplateResponse
|
from django.template.response import SimpleTemplateResponse
|
||||||
from rest_framework.compat import six
|
from django.utils import six
|
||||||
|
|
||||||
|
|
||||||
class Response(SimpleTemplateResponse):
|
class Response(SimpleTemplateResponse):
|
||||||
|
|
|
@ -20,9 +20,9 @@ from django.contrib.contenttypes.generic import GenericForeignKey
|
||||||
from django.core.paginator import Page
|
from django.core.paginator import Page
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.forms import widgets
|
from django.forms import widgets
|
||||||
|
from django.utils import six
|
||||||
from django.utils.datastructures import SortedDict
|
from django.utils.datastructures import SortedDict
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from rest_framework.compat import six
|
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework.settings import api_settings
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,12 +18,9 @@ REST framework settings, checking for user settings first, then falling
|
||||||
back to the defaults.
|
back to the defaults.
|
||||||
"""
|
"""
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils import importlib
|
from django.utils import importlib, six
|
||||||
|
|
||||||
from rest_framework import ISO_8601
|
from rest_framework import ISO_8601
|
||||||
from rest_framework.compat import six
|
|
||||||
|
|
||||||
|
|
||||||
USER_SETTINGS = getattr(settings, 'REST_FRAMEWORK', None)
|
USER_SETTINGS = getattr(settings, 'REST_FRAMEWORK', None)
|
||||||
|
|
|
@ -2,11 +2,12 @@ from __future__ import unicode_literals, absolute_import
|
||||||
from django import template
|
from django import template
|
||||||
from django.core.urlresolvers import reverse, NoReverseMatch
|
from django.core.urlresolvers import reverse, NoReverseMatch
|
||||||
from django.http import QueryDict
|
from django.http import QueryDict
|
||||||
|
from django.utils import six
|
||||||
from django.utils.encoding import iri_to_uri
|
from django.utils.encoding import iri_to_uri
|
||||||
from django.utils.html import escape
|
from django.utils.html import escape
|
||||||
from django.utils.safestring import SafeData, mark_safe
|
from django.utils.safestring import SafeData, mark_safe
|
||||||
from rest_framework.compat import urlparse, force_text, six
|
|
||||||
from django.utils.html import smart_urlquote
|
from django.utils.html import smart_urlquote
|
||||||
|
from rest_framework.compat import urlparse, force_text
|
||||||
import re
|
import re
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
|
@ -8,10 +8,11 @@ from django.conf import settings
|
||||||
from django.test.client import Client as DjangoClient
|
from django.test.client import Client as DjangoClient
|
||||||
from django.test.client import ClientHandler
|
from django.test.client import ClientHandler
|
||||||
from django.test import testcases
|
from django.test import testcases
|
||||||
|
from django.utils import six
|
||||||
from django.utils.http import urlencode
|
from django.utils.http import urlencode
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework.settings import api_settings
|
||||||
from rest_framework.compat import RequestFactory as DjangoRequestFactory
|
from rest_framework.compat import RequestFactory as DjangoRequestFactory
|
||||||
from rest_framework.compat import force_bytes_or_smart_bytes, six
|
from rest_framework.compat import force_bytes_or_smart_bytes
|
||||||
|
|
||||||
|
|
||||||
def force_authenticate(request, user=None, token=None):
|
def force_authenticate(request, user=None, token=None):
|
||||||
|
|
|
@ -3,7 +3,7 @@ from django.conf.urls import patterns, url, include
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.utils import unittest
|
from django.utils import six, unittest
|
||||||
from django.utils.http import urlencode
|
from django.utils.http import urlencode
|
||||||
from rest_framework import HTTP_HEADER_ENCODING
|
from rest_framework import HTTP_HEADER_ENCODING
|
||||||
from rest_framework import exceptions
|
from rest_framework import exceptions
|
||||||
|
@ -20,7 +20,6 @@ from rest_framework.authentication import (
|
||||||
OAuth2Authentication
|
OAuth2Authentication
|
||||||
)
|
)
|
||||||
from rest_framework.authtoken.models import Token
|
from rest_framework.authtoken.models import Token
|
||||||
from rest_framework.compat import six
|
|
||||||
from rest_framework.compat import oauth2_provider, oauth2_provider_scope
|
from rest_framework.compat import oauth2_provider, oauth2_provider_scope
|
||||||
from rest_framework.compat import oauth, oauth_provider
|
from rest_framework.compat import oauth, oauth_provider
|
||||||
from rest_framework.test import APIRequestFactory, APIClient
|
from rest_framework.test import APIRequestFactory, APIClient
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
from django.utils import six
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_framework.compat import BytesIO
|
from rest_framework.compat import BytesIO
|
||||||
from rest_framework.compat import six
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,11 @@ from __future__ import unicode_literals
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
from django.utils import six
|
||||||
from rest_framework import generics, renderers, serializers, status
|
from rest_framework import generics, renderers, serializers, status
|
||||||
from rest_framework.test import APIRequestFactory
|
from rest_framework.test import APIRequestFactory
|
||||||
from tests.models import BasicModel, Comment, SlugBasedModel
|
from tests.models import BasicModel, Comment, SlugBasedModel
|
||||||
from tests.models import ForeignKeySource, ForeignKeyTarget
|
from tests.models import ForeignKeySource, ForeignKeyTarget
|
||||||
from rest_framework.compat import six
|
|
||||||
|
|
||||||
factory = APIRequestFactory()
|
factory = APIRequestFactory()
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,12 @@ from django.conf.urls import patterns, url
|
||||||
from django.http import Http404
|
from django.http import Http404
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.template import TemplateDoesNotExist, Template
|
from django.template import TemplateDoesNotExist, Template
|
||||||
import django.template.loader
|
from django.utils import six
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from rest_framework.decorators import api_view, renderer_classes
|
from rest_framework.decorators import api_view, renderer_classes
|
||||||
from rest_framework.renderers import TemplateHTMLRenderer
|
from rest_framework.renderers import TemplateHTMLRenderer
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.compat import six
|
import django.template.loader
|
||||||
|
|
||||||
|
|
||||||
@api_view(('GET',))
|
@api_view(('GET',))
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
from django.utils import six
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from tests.models import (
|
from tests.models import (
|
||||||
BlogPost, ManyToManyTarget, ManyToManySource, ForeignKeyTarget, ForeignKeySource,
|
BlogPost, ManyToManyTarget, ManyToManySource, ForeignKeyTarget, ForeignKeySource,
|
||||||
NullableForeignKeySource, OneToOneTarget, NullableOneToOneSource,
|
NullableForeignKeySource, OneToOneTarget, NullableOneToOneSource,
|
||||||
)
|
)
|
||||||
from rest_framework.compat import six
|
|
||||||
|
|
||||||
|
|
||||||
# ManyToMany
|
# ManyToMany
|
||||||
|
|
|
@ -6,10 +6,10 @@ from django.conf.urls import patterns, url, include
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.utils import unittest
|
from django.utils import six, unittest
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from rest_framework import status, permissions
|
from rest_framework import status, permissions
|
||||||
from rest_framework.compat import yaml, etree, six, StringIO
|
from rest_framework.compat import yaml, etree, StringIO
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
from rest_framework.renderers import BaseRenderer, JSONRenderer, YAMLRenderer, \
|
from rest_framework.renderers import BaseRenderer, JSONRenderer, YAMLRenderer, \
|
||||||
|
|
|
@ -8,6 +8,7 @@ from django.contrib.auth import authenticate, login, logout
|
||||||
from django.contrib.sessions.middleware import SessionMiddleware
|
from django.contrib.sessions.middleware import SessionMiddleware
|
||||||
from django.core.handlers.wsgi import WSGIRequest
|
from django.core.handlers.wsgi import WSGIRequest
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
from django.utils import six
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from rest_framework.authentication import SessionAuthentication
|
from rest_framework.authentication import SessionAuthentication
|
||||||
from rest_framework.parsers import (
|
from rest_framework.parsers import (
|
||||||
|
@ -21,7 +22,6 @@ from rest_framework.response import Response
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework.settings import api_settings
|
||||||
from rest_framework.test import APIRequestFactory, APIClient
|
from rest_framework.test import APIRequestFactory, APIClient
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
from rest_framework.compat import six
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from django.conf.urls import patterns, url, include
|
from django.conf.urls import patterns, url, include
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
from django.utils import six
|
||||||
from tests.models import BasicModel, BasicModelSerializer
|
from tests.models import BasicModel, BasicModelSerializer
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
|
@ -14,7 +15,6 @@ from rest_framework.renderers import (
|
||||||
)
|
)
|
||||||
from rest_framework import viewsets
|
from rest_framework import viewsets
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework.settings import api_settings
|
||||||
from rest_framework.compat import six
|
|
||||||
|
|
||||||
|
|
||||||
class MockPickleRenderer(BaseRenderer):
|
class MockPickleRenderer(BaseRenderer):
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from rest_framework.compat import six
|
from django.utils import six
|
||||||
from rest_framework.serializers import _resolve_model
|
from rest_framework.serializers import _resolve_model
|
||||||
from tests.models import BasicModel
|
from tests.models import BasicModel
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from rest_framework.compat import six
|
from django.utils import six
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework.settings import api_settings
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user