Merge 72a7020d40
into 2eb9107b87
|
@ -1,9 +1,9 @@
|
||||||
[main]
|
[main]
|
||||||
host = https://www.transifex.com
|
host = https://www.transifex.com
|
||||||
|
|
||||||
[django-rest-framework.djangopo]
|
[django-rest-framework-3.djangopo]
|
||||||
file_filter = rest_framework/locale/<lang>/LC_MESSAGES/django.po
|
file_filter = rest_framework_3/locale/<lang>/LC_MESSAGES/django.po
|
||||||
source_file = rest_framework/locale/en_US/LC_MESSAGES/django.po
|
source_file = rest_framework_3/locale/en_US/LC_MESSAGES/django.po
|
||||||
source_lang = en_US
|
source_lang = en_US
|
||||||
type = PO
|
type = PO
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
recursive-include rest_framework/static *.js *.css *.png *.eot *.svg *.ttf *.woff
|
recursive-include rest_framework_3/static *.js *.css *.png *.eot *.svg *.ttf *.woff
|
||||||
recursive-include rest_framework/templates *.html
|
recursive-include rest_framework_3/templates *.html
|
||||||
recursive-exclude * __pycache__
|
recursive-exclude * __pycache__
|
||||||
recursive-exclude * *.py[co]
|
recursive-exclude * *.py[co]
|
||||||
|
|
12
README.md
|
@ -44,11 +44,11 @@ Install using `pip`...
|
||||||
|
|
||||||
pip install djangorestframework
|
pip install djangorestframework
|
||||||
|
|
||||||
Add `'rest_framework'` to your `INSTALLED_APPS` setting.
|
Add `'rest_framework_3'` to your `INSTALLED_APPS` setting.
|
||||||
|
|
||||||
INSTALLED_APPS = (
|
INSTALLED_APPS = (
|
||||||
...
|
...
|
||||||
'rest_framework',
|
'rest_framework_3',
|
||||||
)
|
)
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
@ -67,7 +67,7 @@ Now edit the `example/urls.py` module in your project:
|
||||||
```python
|
```python
|
||||||
from django.conf.urls import url, include
|
from django.conf.urls import url, include
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from rest_framework import serializers, viewsets, routers
|
from rest_framework_3 import serializers, viewsets, routers
|
||||||
|
|
||||||
# Serializers define the API representation.
|
# Serializers define the API representation.
|
||||||
class UserSerializer(serializers.HyperlinkedModelSerializer):
|
class UserSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
@ -91,7 +91,7 @@ router.register(r'users', UserViewSet)
|
||||||
# Additionally, we include login URLs for the browsable API.
|
# Additionally, we include login URLs for the browsable API.
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^', include(router.urls)),
|
url(r'^', include(router.urls)),
|
||||||
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))
|
url(r'^api-auth/', include('rest_framework_3.urls', namespace='rest_framework_3'))
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -102,14 +102,14 @@ Add the following to your `settings.py` module:
|
||||||
```python
|
```python
|
||||||
INSTALLED_APPS = (
|
INSTALLED_APPS = (
|
||||||
... # Make sure to include the default installed apps here.
|
... # Make sure to include the default installed apps here.
|
||||||
'rest_framework',
|
'rest_framework_3',
|
||||||
)
|
)
|
||||||
|
|
||||||
REST_FRAMEWORK = {
|
REST_FRAMEWORK = {
|
||||||
# Use Django's standard `django.contrib.auth` permissions,
|
# Use Django's standard `django.contrib.auth` permissions,
|
||||||
# or allow read-only access for unauthenticated users.
|
# or allow read-only access for unauthenticated users.
|
||||||
'DEFAULT_PERMISSION_CLASSES': [
|
'DEFAULT_PERMISSION_CLASSES': [
|
||||||
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
|
'rest_framework_3.permissions.DjangoModelPermissionsOrAnonReadOnly'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -6,8 +6,8 @@ import base64
|
||||||
from django.contrib.auth import authenticate
|
from django.contrib.auth import authenticate
|
||||||
from django.middleware.csrf import CsrfViewMiddleware
|
from django.middleware.csrf import CsrfViewMiddleware
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from rest_framework import exceptions, HTTP_HEADER_ENCODING
|
from rest_framework_3 import exceptions, HTTP_HEADER_ENCODING
|
||||||
from rest_framework.authtoken.models import Token
|
from rest_framework_3.authtoken.models import Token
|
||||||
|
|
||||||
|
|
||||||
def get_authorization_header(request):
|
def get_authorization_header(request):
|
|
@ -1,5 +1,5 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from rest_framework.authtoken.models import Token
|
from rest_framework_3.authtoken.models import Token
|
||||||
|
|
||||||
|
|
||||||
class TokenAdmin(admin.ModelAdmin):
|
class TokenAdmin(admin.ModelAdmin):
|
|
@ -28,7 +28,7 @@ class Token(models.Model):
|
||||||
#
|
#
|
||||||
# Also see corresponding ticket:
|
# Also see corresponding ticket:
|
||||||
# https://github.com/tomchristie/django-rest-framework/issues/705
|
# https://github.com/tomchristie/django-rest-framework/issues/705
|
||||||
abstract = 'rest_framework.authtoken' not in settings.INSTALLED_APPS
|
abstract = 'rest_framework_3.authtoken' not in settings.INSTALLED_APPS
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if not self.key:
|
if not self.key:
|
|
@ -1,7 +1,7 @@
|
||||||
from django.contrib.auth import authenticate
|
from django.contrib.auth import authenticate
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from rest_framework import exceptions, serializers
|
from rest_framework_3 import exceptions, serializers
|
||||||
|
|
||||||
|
|
||||||
class AuthTokenSerializer(serializers.Serializer):
|
class AuthTokenSerializer(serializers.Serializer):
|
|
@ -1,9 +1,9 @@
|
||||||
from rest_framework.views import APIView
|
from rest_framework_3.views import APIView
|
||||||
from rest_framework import parsers
|
from rest_framework_3 import parsers
|
||||||
from rest_framework import renderers
|
from rest_framework_3 import renderers
|
||||||
from rest_framework.response import Response
|
from rest_framework_3.response import Response
|
||||||
from rest_framework.authtoken.models import Token
|
from rest_framework_3.authtoken.models import Token
|
||||||
from rest_framework.authtoken.serializers import AuthTokenSerializer
|
from rest_framework_3.authtoken.serializers import AuthTokenSerializer
|
||||||
|
|
||||||
|
|
||||||
class ObtainAuthToken(APIView):
|
class ObtainAuthToken(APIView):
|
|
@ -8,7 +8,7 @@ used to annotate methods on viewsets that should be included by routers.
|
||||||
"""
|
"""
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
from rest_framework.views import APIView
|
from rest_framework_3.views import APIView
|
||||||
import types
|
import types
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ from __future__ import unicode_literals
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
from django.utils.encoding import force_text
|
from django.utils.encoding import force_text
|
||||||
from django.utils.translation import ugettext_lazy as _, ungettext
|
from django.utils.translation import ugettext_lazy as _, ungettext
|
||||||
from rest_framework import status
|
from rest_framework_3 import status
|
||||||
import math
|
import math
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ class APIException(Exception):
|
||||||
# under `serializers`, in order to minimize potential confusion with Django's
|
# under `serializers`, in order to minimize potential confusion with Django's
|
||||||
# built in `ValidationError`. For example:
|
# built in `ValidationError`. For example:
|
||||||
#
|
#
|
||||||
# from rest_framework import serializers
|
# from rest_framework_3 import serializers
|
||||||
# raise serializers.ValidationError('Value was invalid')
|
# raise serializers.ValidationError('Value was invalid')
|
||||||
|
|
||||||
class ValidationError(APIException):
|
class ValidationError(APIException):
|
|
@ -8,15 +8,15 @@ from django.utils import six, timezone
|
||||||
from django.utils.dateparse import parse_date, parse_datetime, parse_time
|
from django.utils.dateparse import parse_date, parse_datetime, parse_time
|
||||||
from django.utils.encoding import is_protected_type, smart_text
|
from django.utils.encoding import is_protected_type, smart_text
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from rest_framework import ISO_8601
|
from rest_framework_3 import ISO_8601
|
||||||
from rest_framework.compat import (
|
from rest_framework_3.compat import (
|
||||||
EmailValidator, MinValueValidator, MaxValueValidator,
|
EmailValidator, MinValueValidator, MaxValueValidator,
|
||||||
MinLengthValidator, MaxLengthValidator, URLValidator, OrderedDict,
|
MinLengthValidator, MaxLengthValidator, URLValidator, OrderedDict,
|
||||||
unicode_repr, unicode_to_repr
|
unicode_repr, unicode_to_repr
|
||||||
)
|
)
|
||||||
from rest_framework.exceptions import ValidationError
|
from rest_framework_3.exceptions import ValidationError
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework_3.settings import api_settings
|
||||||
from rest_framework.utils import html, representation, humanize_datetime
|
from rest_framework_3.utils import html, representation, humanize_datetime
|
||||||
import collections
|
import collections
|
||||||
import copy
|
import copy
|
||||||
import datetime
|
import datetime
|
|
@ -7,8 +7,8 @@ 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 django.utils import six
|
from django.utils import six
|
||||||
from rest_framework.compat import django_filters, guardian, get_model_name
|
from rest_framework_3.compat import django_filters, guardian, get_model_name
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework_3.settings import api_settings
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
import operator
|
import operator
|
||||||
|
|
|
@ -5,8 +5,8 @@ from __future__ import unicode_literals
|
||||||
from django.db.models.query import QuerySet
|
from django.db.models.query import QuerySet
|
||||||
from django.http import Http404
|
from django.http import Http404
|
||||||
from django.shortcuts import get_object_or_404 as _get_object_or_404
|
from django.shortcuts import get_object_or_404 as _get_object_or_404
|
||||||
from rest_framework import views, mixins
|
from rest_framework_3 import views, mixins
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework_3.settings import api_settings
|
||||||
|
|
||||||
|
|
||||||
def get_object_or_404(queryset, *filter_args, **filter_kwargs):
|
def get_object_or_404(queryset, *filter_args, **filter_kwargs):
|
|
@ -11,10 +11,10 @@ from __future__ import unicode_literals
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.http import Http404
|
from django.http import Http404
|
||||||
from django.utils.encoding import force_text
|
from django.utils.encoding import force_text
|
||||||
from rest_framework import exceptions, serializers
|
from rest_framework_3 import exceptions, serializers
|
||||||
from rest_framework.compat import OrderedDict
|
from rest_framework_3.compat import OrderedDict
|
||||||
from rest_framework.request import clone_request
|
from rest_framework_3.request import clone_request
|
||||||
from rest_framework.utils.field_mapping import ClassLookupDict
|
from rest_framework_3.utils.field_mapping import ClassLookupDict
|
||||||
|
|
||||||
|
|
||||||
class BaseMetadata(object):
|
class BaseMetadata(object):
|
|
@ -5,9 +5,9 @@ We don't bind behaviour to http method handlers yet,
|
||||||
which allows mixin classes to be composed in interesting ways.
|
which allows mixin classes to be composed in interesting ways.
|
||||||
"""
|
"""
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from rest_framework import status
|
from rest_framework_3 import status
|
||||||
from rest_framework.response import Response
|
from rest_framework_3.response import Response
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework_3.settings import api_settings
|
||||||
|
|
||||||
|
|
||||||
class CreateModelMixin(object):
|
class CreateModelMixin(object):
|
|
@ -4,10 +4,10 @@ incoming request. Typically this will be based on the request's Accept header.
|
||||||
"""
|
"""
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from django.http import Http404
|
from django.http import Http404
|
||||||
from rest_framework import HTTP_HEADER_ENCODING, exceptions
|
from rest_framework_3 import HTTP_HEADER_ENCODING, exceptions
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework_3.settings import api_settings
|
||||||
from rest_framework.utils.mediatypes import order_by_precedence, media_type_matches
|
from rest_framework_3.utils.mediatypes import order_by_precedence, media_type_matches
|
||||||
from rest_framework.utils.mediatypes import _MediaType
|
from rest_framework_3.utils.mediatypes import _MediaType
|
||||||
|
|
||||||
|
|
||||||
class BaseContentNegotiation(object):
|
class BaseContentNegotiation(object):
|
|
@ -11,11 +11,11 @@ from django.template import Context, loader
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
from django.utils.six.moves.urllib import parse as urlparse
|
from django.utils.six.moves.urllib import parse as urlparse
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from rest_framework.compat import OrderedDict
|
from rest_framework_3.compat import OrderedDict
|
||||||
from rest_framework.exceptions import NotFound
|
from rest_framework_3.exceptions import NotFound
|
||||||
from rest_framework.response import Response
|
from rest_framework_3.response import Response
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework_3.settings import api_settings
|
||||||
from rest_framework.utils.urls import (
|
from rest_framework_3.utils.urls import (
|
||||||
replace_query_param, remove_query_param
|
replace_query_param, remove_query_param
|
||||||
)
|
)
|
||||||
import warnings
|
import warnings
|
|
@ -14,8 +14,8 @@ from django.http.multipartparser import MultiPartParserError, parse_header, Chun
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
from django.utils.six.moves.urllib import parse as urlparse
|
from django.utils.six.moves.urllib import parse as urlparse
|
||||||
from django.utils.encoding import force_text
|
from django.utils.encoding import force_text
|
||||||
from rest_framework.exceptions import ParseError
|
from rest_framework_3.exceptions import ParseError
|
||||||
from rest_framework import renderers
|
from rest_framework_3 import renderers
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ Provides a set of pluggable permission policies.
|
||||||
"""
|
"""
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from django.http import Http404
|
from django.http import Http404
|
||||||
from rest_framework.compat import get_model_name
|
from rest_framework_3.compat import get_model_name
|
||||||
|
|
||||||
SAFE_METHODS = ('GET', 'HEAD', 'OPTIONS')
|
SAFE_METHODS = ('GET', 'HEAD', 'OPTIONS')
|
||||||
|
|
|
@ -7,10 +7,10 @@ from django.utils import six
|
||||||
from django.utils.encoding import smart_text
|
from django.utils.encoding import smart_text
|
||||||
from django.utils.six.moves.urllib import parse as urlparse
|
from django.utils.six.moves.urllib import parse as urlparse
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from rest_framework.compat import OrderedDict
|
from rest_framework_3.compat import OrderedDict
|
||||||
from rest_framework.fields import get_attribute, empty, Field
|
from rest_framework_3.fields import get_attribute, empty, Field
|
||||||
from rest_framework.reverse import reverse
|
from rest_framework_3.reverse import reverse
|
||||||
from rest_framework.utils import html
|
from rest_framework_3.utils import html
|
||||||
|
|
||||||
|
|
||||||
class PKOnlyObject(object):
|
class PKOnlyObject(object):
|
|
@ -17,14 +17,14 @@ from django.http.multipartparser import parse_header
|
||||||
from django.template import Context, RequestContext, loader, Template
|
from django.template import Context, 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 import six
|
||||||
from rest_framework import exceptions, serializers, status, VERSION
|
from rest_framework_3 import exceptions, serializers, status, VERSION
|
||||||
from rest_framework.compat import SHORT_SEPARATORS, LONG_SEPARATORS, INDENT_SEPARATORS
|
from rest_framework_3.compat import SHORT_SEPARATORS, LONG_SEPARATORS, INDENT_SEPARATORS
|
||||||
from rest_framework.exceptions import ParseError
|
from rest_framework_3.exceptions import ParseError
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework_3.settings import api_settings
|
||||||
from rest_framework.request import is_form_media_type, override_method
|
from rest_framework_3.request import is_form_media_type, override_method
|
||||||
from rest_framework.utils import encoders
|
from rest_framework_3.utils import encoders
|
||||||
from rest_framework.utils.breadcrumbs import get_breadcrumbs
|
from rest_framework_3.utils.breadcrumbs import get_breadcrumbs
|
||||||
from rest_framework.utils.field_mapping import ClassLookupDict
|
from rest_framework_3.utils.field_mapping import ClassLookupDict
|
||||||
|
|
||||||
|
|
||||||
def zero_as_none(value):
|
def zero_as_none(value):
|
|
@ -14,9 +14,9 @@ from django.http import QueryDict
|
||||||
from django.http.multipartparser import parse_header
|
from django.http.multipartparser import parse_header
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
from django.utils.datastructures import MultiValueDict
|
from django.utils.datastructures import MultiValueDict
|
||||||
from rest_framework import HTTP_HEADER_ENCODING
|
from rest_framework_3 import HTTP_HEADER_ENCODING
|
||||||
from rest_framework import exceptions
|
from rest_framework_3 import exceptions
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework_3.settings import api_settings
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
|
|
|
@ -20,11 +20,11 @@ from collections import namedtuple
|
||||||
from django.conf.urls import patterns, url
|
from django.conf.urls import patterns, url
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.core.urlresolvers import NoReverseMatch
|
from django.core.urlresolvers import NoReverseMatch
|
||||||
from rest_framework import views
|
from rest_framework_3 import views
|
||||||
from rest_framework.compat import get_resolver_match, OrderedDict
|
from rest_framework_3.compat import get_resolver_match, OrderedDict
|
||||||
from rest_framework.response import Response
|
from rest_framework_3.response import Response
|
||||||
from rest_framework.reverse import reverse
|
from rest_framework_3.reverse import reverse
|
||||||
from rest_framework.urlpatterns import format_suffix_patterns
|
from rest_framework_3.urlpatterns import format_suffix_patterns
|
||||||
|
|
||||||
|
|
||||||
Route = namedtuple('Route', ['url', 'mapping', 'name', 'initkwargs'])
|
Route = namedtuple('Route', ['url', 'mapping', 'name', 'initkwargs'])
|
|
@ -15,17 +15,17 @@ from django.db import models
|
||||||
from django.db.models.fields import FieldDoesNotExist, Field as DjangoModelField
|
from django.db.models.fields import FieldDoesNotExist, Field as DjangoModelField
|
||||||
from django.db.models import query
|
from django.db.models import query
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from rest_framework.compat import postgres_fields, unicode_to_repr
|
from rest_framework_3.compat import postgres_fields, unicode_to_repr
|
||||||
from rest_framework.utils import model_meta
|
from rest_framework_3.utils import model_meta
|
||||||
from rest_framework.utils.field_mapping import (
|
from rest_framework_3.utils.field_mapping import (
|
||||||
get_url_kwargs, get_field_kwargs,
|
get_url_kwargs, get_field_kwargs,
|
||||||
get_relation_kwargs, get_nested_relation_kwargs,
|
get_relation_kwargs, get_nested_relation_kwargs,
|
||||||
ClassLookupDict
|
ClassLookupDict
|
||||||
)
|
)
|
||||||
from rest_framework.utils.serializer_helpers import (
|
from rest_framework_3.utils.serializer_helpers import (
|
||||||
ReturnDict, ReturnList, BoundField, NestedBoundField, BindingDict
|
ReturnDict, ReturnList, BoundField, NestedBoundField, BindingDict
|
||||||
)
|
)
|
||||||
from rest_framework.validators import (
|
from rest_framework_3.validators import (
|
||||||
UniqueForDateValidator, UniqueForMonthValidator, UniqueForYearValidator,
|
UniqueForDateValidator, UniqueForMonthValidator, UniqueForYearValidator,
|
||||||
UniqueTogetherValidator
|
UniqueTogetherValidator
|
||||||
)
|
)
|
||||||
|
@ -39,8 +39,8 @@ import warnings
|
||||||
# This helps keep the separation between model fields, form fields, and
|
# This helps keep the separation between model fields, form fields, and
|
||||||
# serializer fields more explicit.
|
# serializer fields more explicit.
|
||||||
|
|
||||||
from rest_framework.relations import * # NOQA
|
from rest_framework_3.relations import * # NOQA
|
||||||
from rest_framework.fields import * # NOQA
|
from rest_framework_3.fields import * # NOQA
|
||||||
|
|
||||||
|
|
||||||
# We assume that 'validators' are intended for the child serializer,
|
# We assume that 'validators' are intended for the child serializer,
|
|
@ -4,12 +4,12 @@ For example your project's `settings.py` file might look like this:
|
||||||
|
|
||||||
REST_FRAMEWORK = {
|
REST_FRAMEWORK = {
|
||||||
'DEFAULT_RENDERER_CLASSES': (
|
'DEFAULT_RENDERER_CLASSES': (
|
||||||
'rest_framework.renderers.JSONRenderer',
|
'rest_framework_3.renderers.JSONRenderer',
|
||||||
'rest_framework.renderers.TemplateHTMLRenderer',
|
'rest_framework_3.renderers.TemplateHTMLRenderer',
|
||||||
)
|
)
|
||||||
'DEFAULT_PARSER_CLASSES': (
|
'DEFAULT_PARSER_CLASSES': (
|
||||||
'rest_framework.parsers.JSONParser',
|
'rest_framework_3.parsers.JSONParser',
|
||||||
'rest_framework.parsers.TemplateHTMLRenderer',
|
'rest_framework_3.parsers.TemplateHTMLRenderer',
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,36 +21,36 @@ from __future__ import unicode_literals
|
||||||
from django.test.signals import setting_changed
|
from django.test.signals import setting_changed
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
from rest_framework import ISO_8601
|
from rest_framework_3 import ISO_8601
|
||||||
from rest_framework.compat import importlib
|
from rest_framework_3.compat import importlib
|
||||||
|
|
||||||
USER_SETTINGS = getattr(settings, 'REST_FRAMEWORK', None)
|
USER_SETTINGS = getattr(settings, 'REST_FRAMEWORK_3', None)
|
||||||
|
|
||||||
DEFAULTS = {
|
DEFAULTS = {
|
||||||
# Base API policies
|
# Base API policies
|
||||||
'DEFAULT_RENDERER_CLASSES': (
|
'DEFAULT_RENDERER_CLASSES': (
|
||||||
'rest_framework.renderers.JSONRenderer',
|
'rest_framework_3.renderers.JSONRenderer',
|
||||||
'rest_framework.renderers.BrowsableAPIRenderer',
|
'rest_framework_3.renderers.BrowsableAPIRenderer',
|
||||||
),
|
),
|
||||||
'DEFAULT_PARSER_CLASSES': (
|
'DEFAULT_PARSER_CLASSES': (
|
||||||
'rest_framework.parsers.JSONParser',
|
'rest_framework_3.parsers.JSONParser',
|
||||||
'rest_framework.parsers.FormParser',
|
'rest_framework_3.parsers.FormParser',
|
||||||
'rest_framework.parsers.MultiPartParser'
|
'rest_framework_3.parsers.MultiPartParser'
|
||||||
),
|
),
|
||||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
'DEFAULT_AUTHENTICATION_CLASSES': (
|
||||||
'rest_framework.authentication.SessionAuthentication',
|
'rest_framework_3.authentication.SessionAuthentication',
|
||||||
'rest_framework.authentication.BasicAuthentication'
|
'rest_framework_3.authentication.BasicAuthentication'
|
||||||
),
|
),
|
||||||
'DEFAULT_PERMISSION_CLASSES': (
|
'DEFAULT_PERMISSION_CLASSES': (
|
||||||
'rest_framework.permissions.AllowAny',
|
'rest_framework_3.permissions.AllowAny',
|
||||||
),
|
),
|
||||||
'DEFAULT_THROTTLE_CLASSES': (),
|
'DEFAULT_THROTTLE_CLASSES': (),
|
||||||
'DEFAULT_CONTENT_NEGOTIATION_CLASS': 'rest_framework.negotiation.DefaultContentNegotiation',
|
'DEFAULT_CONTENT_NEGOTIATION_CLASS': 'rest_framework_3.negotiation.DefaultContentNegotiation',
|
||||||
'DEFAULT_METADATA_CLASS': 'rest_framework.metadata.SimpleMetadata',
|
'DEFAULT_METADATA_CLASS': 'rest_framework_3.metadata.SimpleMetadata',
|
||||||
'DEFAULT_VERSIONING_CLASS': None,
|
'DEFAULT_VERSIONING_CLASS': None,
|
||||||
|
|
||||||
# Generic view behavior
|
# Generic view behavior
|
||||||
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
|
'DEFAULT_PAGINATION_CLASS': 'rest_framework_3.pagination.PageNumberPagination',
|
||||||
'DEFAULT_FILTER_BACKENDS': (),
|
'DEFAULT_FILTER_BACKENDS': (),
|
||||||
|
|
||||||
# Throttling
|
# Throttling
|
||||||
|
@ -77,17 +77,17 @@ DEFAULTS = {
|
||||||
'UNAUTHENTICATED_TOKEN': None,
|
'UNAUTHENTICATED_TOKEN': None,
|
||||||
|
|
||||||
# View configuration
|
# View configuration
|
||||||
'VIEW_NAME_FUNCTION': 'rest_framework.views.get_view_name',
|
'VIEW_NAME_FUNCTION': 'rest_framework_3.views.get_view_name',
|
||||||
'VIEW_DESCRIPTION_FUNCTION': 'rest_framework.views.get_view_description',
|
'VIEW_DESCRIPTION_FUNCTION': 'rest_framework_3.views.get_view_description',
|
||||||
|
|
||||||
# Exception handling
|
# Exception handling
|
||||||
'EXCEPTION_HANDLER': 'rest_framework.views.exception_handler',
|
'EXCEPTION_HANDLER': 'rest_framework_3.views.exception_handler',
|
||||||
'NON_FIELD_ERRORS_KEY': 'non_field_errors',
|
'NON_FIELD_ERRORS_KEY': 'non_field_errors',
|
||||||
|
|
||||||
# Testing
|
# Testing
|
||||||
'TEST_REQUEST_RENDERER_CLASSES': (
|
'TEST_REQUEST_RENDERER_CLASSES': (
|
||||||
'rest_framework.renderers.MultiPartRenderer',
|
'rest_framework_3.renderers.MultiPartRenderer',
|
||||||
'rest_framework.renderers.JSONRenderer'
|
'rest_framework_3.renderers.JSONRenderer'
|
||||||
),
|
),
|
||||||
'TEST_REQUEST_DEFAULT_FORMAT': 'multipart',
|
'TEST_REQUEST_DEFAULT_FORMAT': 'multipart',
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ class APISettings(object):
|
||||||
A settings object, that allows API settings to be accessed as properties.
|
A settings object, that allows API settings to be accessed as properties.
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework_3.settings import api_settings
|
||||||
print(api_settings.DEFAULT_RENDERER_CLASSES)
|
print(api_settings.DEFAULT_RENDERER_CLASSES)
|
||||||
|
|
||||||
Any setting with string import paths will be automatically resolved
|
Any setting with string import paths will be automatically resolved
|
||||||
|
@ -216,7 +216,7 @@ api_settings = APISettings(USER_SETTINGS, DEFAULTS, IMPORT_STRINGS)
|
||||||
def reload_api_settings(*args, **kwargs):
|
def reload_api_settings(*args, **kwargs):
|
||||||
global api_settings
|
global api_settings
|
||||||
setting, value = kwargs['setting'], kwargs['value']
|
setting, value = kwargs['setting'], kwargs['value']
|
||||||
if setting == 'REST_FRAMEWORK':
|
if setting == 'REST_FRAMEWORK_3':
|
||||||
api_settings = APISettings(value, DEFAULTS, IMPORT_STRINGS)
|
api_settings = APISettings(value, DEFAULTS, IMPORT_STRINGS)
|
||||||
|
|
||||||
|
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |