mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-25 19:14:01 +03:00
Cleanup import following PEP 8 style guide
This commit is contained in:
parent
47765bc429
commit
83c9136c90
|
@ -2,13 +2,16 @@
|
|||
Provides various authentication policies.
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import base64
|
||||
|
||||
from django.contrib.auth import authenticate
|
||||
from django.middleware.csrf import CsrfViewMiddleware
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from rest_framework import exceptions, HTTP_HEADER_ENCODING
|
||||
from rest_framework.authtoken.models import Token
|
||||
|
||||
from rest_framework.compat import get_user_model
|
||||
from rest_framework.authtoken.models import Token
|
||||
from rest_framework import exceptions, HTTP_HEADER_ENCODING
|
||||
|
||||
|
||||
def get_authorization_header(request):
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from rest_framework.authtoken.models import Token
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import binascii
|
||||
import os
|
||||
import binascii
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from rest_framework import parsers, renderers
|
||||
from rest_framework.views import APIView
|
||||
from rest_framework import parsers
|
||||
from rest_framework import renderers
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.authtoken.models import Token
|
||||
from rest_framework.authtoken.serializers import AuthTokenSerializer
|
||||
|
|
|
@ -5,14 +5,17 @@ versions of django/python, and compatibility wrappers around optional packages.
|
|||
|
||||
# flake8: noqa
|
||||
from __future__ import unicode_literals
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
import inspect
|
||||
|
||||
import django
|
||||
from django.utils import six
|
||||
from django.conf import settings
|
||||
from django.db import connection, transaction
|
||||
from django.utils.encoding import force_text
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.utils.six.moves.urllib.parse import urlparse as _urlparse
|
||||
from django.utils import six
|
||||
import django
|
||||
import inspect
|
||||
|
||||
try:
|
||||
import importlib
|
||||
except ImportError:
|
||||
|
|
|
@ -7,10 +7,13 @@ 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.
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
from django.utils import six
|
||||
from rest_framework.views import APIView
|
||||
|
||||
import types
|
||||
|
||||
from django.utils import six
|
||||
|
||||
from rest_framework.views import APIView
|
||||
|
||||
|
||||
def api_view(http_method_names=None):
|
||||
|
||||
|
|
|
@ -5,11 +5,14 @@ In addition Django's built in 403 and 404 exceptions are handled.
|
|||
(`django.http.Http404` and `django.core.exceptions.PermissionDenied`)
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import math
|
||||
|
||||
from django.utils import six
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.translation import ugettext_lazy as _, ungettext
|
||||
|
||||
from rest_framework import status
|
||||
import math
|
||||
|
||||
|
||||
def _force_text_recursive(data):
|
||||
|
|
|
@ -1,30 +1,34 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import re
|
||||
import copy
|
||||
import uuid
|
||||
import decimal
|
||||
import inspect
|
||||
import datetime
|
||||
import collections
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.core.exceptions import ValidationError as DjangoValidationError
|
||||
from django.core.validators import RegexValidator, ip_address_validators
|
||||
from django.forms import ImageField as DjangoImageField
|
||||
from django.utils import six, timezone
|
||||
from django.utils.dateparse import parse_date, parse_datetime, parse_time
|
||||
from django.utils.encoding import is_protected_type, smart_text
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.ipv6 import clean_ipv6_address
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.forms import ImageField as DjangoImageField
|
||||
from django.utils.encoding import is_protected_type, smart_text
|
||||
from django.core.validators import RegexValidator, ip_address_validators
|
||||
from django.utils.dateparse import parse_date, parse_datetime, parse_time
|
||||
from django.core.exceptions import (
|
||||
ObjectDoesNotExist, ValidationError as DjangoValidationError
|
||||
)
|
||||
|
||||
from rest_framework import ISO_8601
|
||||
from rest_framework.settings import api_settings
|
||||
from rest_framework.exceptions import ValidationError
|
||||
from rest_framework.utils import html, representation, humanize_datetime
|
||||
from rest_framework.compat import (
|
||||
EmailValidator, MinValueValidator, MaxValueValidator,
|
||||
MinLengthValidator, MaxLengthValidator, URLValidator, OrderedDict,
|
||||
unicode_repr, unicode_to_repr, parse_duration, duration_string,
|
||||
)
|
||||
from rest_framework.exceptions import ValidationError
|
||||
from rest_framework.settings import api_settings
|
||||
from rest_framework.utils import html, representation, humanize_datetime
|
||||
import collections
|
||||
import copy
|
||||
import datetime
|
||||
import decimal
|
||||
import inspect
|
||||
import re
|
||||
import uuid
|
||||
|
||||
|
||||
class empty:
|
||||
|
|
|
@ -4,13 +4,16 @@ returned by list views.
|
|||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.db import models
|
||||
from django.utils import six
|
||||
from rest_framework.compat import django_filters, guardian, get_model_name
|
||||
from rest_framework.settings import api_settings
|
||||
from functools import reduce
|
||||
import operator
|
||||
from functools import reduce
|
||||
|
||||
from django.utils import six
|
||||
from django.db import models
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
from rest_framework.settings import api_settings
|
||||
from rest_framework.compat import django_filters, guardian, get_model_name
|
||||
|
||||
|
||||
FilterSet = django_filters and django_filters.FilterSet or None
|
||||
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
Generic views that provide commonly needed behaviour.
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
from django.db.models.query import QuerySet
|
||||
|
||||
from django.http import Http404
|
||||
from django.db.models.query import QuerySet
|
||||
from django.shortcuts import get_object_or_404 as _get_object_or_404
|
||||
|
||||
from rest_framework import views, mixins
|
||||
from rest_framework.settings import api_settings
|
||||
|
||||
|
|
|
@ -8,9 +8,10 @@ to return this information in a more standardized way.
|
|||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.http import Http404
|
||||
from django.utils.encoding import force_text
|
||||
from django.core.exceptions import PermissionDenied
|
||||
|
||||
from rest_framework import exceptions, serializers
|
||||
from rest_framework.compat import OrderedDict
|
||||
from rest_framework.request import clone_request
|
||||
|
|
|
@ -5,6 +5,7 @@ We don't bind behaviour to http method handlers yet,
|
|||
which allows mixin classes to be composed in interesting ways.
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from rest_framework import status
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.settings import api_settings
|
||||
|
|
|
@ -3,11 +3,14 @@ Content negotiation deals with selecting an appropriate renderer given the
|
|||
incoming request. Typically this will be based on the request's Accept header.
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.http import Http404
|
||||
|
||||
from rest_framework import HTTP_HEADER_ENCODING, exceptions
|
||||
from rest_framework.settings import api_settings
|
||||
from rest_framework.utils.mediatypes import order_by_precedence, media_type_matches
|
||||
from rest_framework.utils.mediatypes import _MediaType
|
||||
from rest_framework.utils.mediatypes import (
|
||||
_MediaType, order_by_precedence, media_type_matches
|
||||
)
|
||||
|
||||
|
||||
class BaseContentNegotiation(object):
|
||||
|
|
|
@ -4,21 +4,24 @@ Pagination serializers determine the structure of the output that should
|
|||
be used for paginated responses.
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import warnings
|
||||
from base64 import b64encode, b64decode
|
||||
from collections import namedtuple
|
||||
from django.core.paginator import InvalidPage, Paginator as DjangoPaginator
|
||||
from django.template import Context, loader
|
||||
|
||||
from django.utils import six
|
||||
from django.utils.six.moves.urllib import parse as urlparse
|
||||
from django.template import Context, loader
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.six.moves.urllib import parse as urlparse
|
||||
from django.core.paginator import InvalidPage, Paginator as DjangoPaginator
|
||||
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.compat import OrderedDict
|
||||
from rest_framework.exceptions import NotFound
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.settings import api_settings
|
||||
from rest_framework.utils.urls import (
|
||||
replace_query_param, remove_query_param
|
||||
)
|
||||
import warnings
|
||||
|
||||
|
||||
def _positive_int(integer_string, strict=False, cutoff=None):
|
||||
|
|
|
@ -6,18 +6,22 @@ on the request, such as form content or json encoded data.
|
|||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.files.uploadhandler import StopFutureHandlers
|
||||
from django.http import QueryDict
|
||||
from django.http.multipartparser import MultiPartParser as DjangoMultiPartParser
|
||||
from django.http.multipartparser import MultiPartParserError, parse_header, ChunkIter
|
||||
from django.utils import six
|
||||
from django.utils.six.moves.urllib import parse as urlparse
|
||||
from django.utils.encoding import force_text
|
||||
from rest_framework.exceptions import ParseError
|
||||
from rest_framework import renderers
|
||||
import json
|
||||
|
||||
from django.utils import six
|
||||
from django.conf import settings
|
||||
from django.http import QueryDict
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.six.moves.urllib import parse as urlparse
|
||||
from django.core.files.uploadhandler import StopFutureHandlers
|
||||
from django.http.multipartparser import (
|
||||
MultiPartParserError, parse_header, ChunkIter,
|
||||
MultiPartParser as DjangoMultiPartParser
|
||||
)
|
||||
|
||||
from rest_framework import renderers
|
||||
from rest_framework.exceptions import ParseError
|
||||
|
||||
|
||||
class DataAndFiles(object):
|
||||
def __init__(self, data, files):
|
||||
|
|
|
@ -2,9 +2,12 @@
|
|||
Provides a set of pluggable permission policies.
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.http import Http404
|
||||
|
||||
from rest_framework.compat import get_model_name
|
||||
|
||||
|
||||
SAFE_METHODS = ('GET', 'HEAD', 'OPTIONS')
|
||||
|
||||
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
# coding: utf-8
|
||||
from __future__ import unicode_literals
|
||||
from django.core.exceptions import ObjectDoesNotExist, ImproperlyConfigured
|
||||
from django.core.urlresolvers import get_script_prefix, resolve, NoReverseMatch, Resolver404
|
||||
from django.db.models.query import QuerySet
|
||||
|
||||
from django.utils import six
|
||||
from django.db.models.query import QuerySet
|
||||
from django.utils.encoding import smart_text
|
||||
from django.utils.six.moves.urllib import parse as urlparse
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.six.moves.urllib import parse as urlparse
|
||||
from django.core.exceptions import ObjectDoesNotExist, ImproperlyConfigured
|
||||
from django.core.urlresolvers import (
|
||||
get_script_prefix, resolve, NoReverseMatch, Resolver404
|
||||
)
|
||||
|
||||
from rest_framework.utils import html
|
||||
from rest_framework.reverse import reverse
|
||||
from rest_framework.compat import OrderedDict
|
||||
from rest_framework.fields import get_attribute, empty, Field
|
||||
from rest_framework.reverse import reverse
|
||||
from rest_framework.utils import html
|
||||
|
||||
|
||||
class PKOnlyObject(object):
|
||||
|
|
|
@ -9,22 +9,26 @@ REST framework also provides an HTML renderer the renders the browsable API.
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import json
|
||||
|
||||
import django
|
||||
from django import forms
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.core.paginator import Page
|
||||
from django.http.multipartparser import parse_header
|
||||
from django.template import Context, RequestContext, loader, Template
|
||||
from django.test.client import encode_multipart
|
||||
from django.utils import six
|
||||
from rest_framework import exceptions, serializers, status, VERSION
|
||||
from rest_framework.compat import SHORT_SEPARATORS, LONG_SEPARATORS, INDENT_SEPARATORS
|
||||
from django.core.paginator import Page
|
||||
from django.test.client import encode_multipart
|
||||
from django.http.multipartparser import parse_header
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.template import Context, RequestContext, loader, Template
|
||||
|
||||
from rest_framework.utils import encoders
|
||||
from rest_framework.exceptions import ParseError
|
||||
from rest_framework.settings import api_settings
|
||||
from rest_framework.request import is_form_media_type, override_method
|
||||
from rest_framework.utils import encoders
|
||||
from rest_framework.utils.breadcrumbs import get_breadcrumbs
|
||||
from rest_framework.utils.field_mapping import ClassLookupDict
|
||||
from rest_framework import exceptions, serializers, status, VERSION
|
||||
from rest_framework.request import is_form_media_type, override_method
|
||||
from rest_framework.compat import (
|
||||
SHORT_SEPARATORS, LONG_SEPARATORS, INDENT_SEPARATORS
|
||||
)
|
||||
|
||||
|
||||
def zero_as_none(value):
|
||||
|
|
|
@ -9,16 +9,18 @@ The wrapped request then offers a richer API, in particular :
|
|||
- form overloading of HTTP method, content type and content
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
from django.utils import six
|
||||
from django.conf import settings
|
||||
from django.http import QueryDict
|
||||
from django.http.multipartparser import parse_header
|
||||
from django.utils import six
|
||||
from django.utils.datastructures import MultiValueDict
|
||||
from rest_framework import HTTP_HEADER_ENCODING
|
||||
from rest_framework import exceptions
|
||||
|
||||
from rest_framework import exceptions, HTTP_HEADER_ENCODING
|
||||
from rest_framework.settings import api_settings
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
|
||||
def is_form_media_type(media_type):
|
||||
|
|
|
@ -5,9 +5,10 @@ it is initialized with unrendered data, instead of a pre-rendered string.
|
|||
The appropriate renderer is called during Django's template response rendering.
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.utils import six
|
||||
from django.utils.six.moves.http_client import responses
|
||||
from django.template.response import SimpleTemplateResponse
|
||||
from django.utils import six
|
||||
|
||||
|
||||
class Response(SimpleTemplateResponse):
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
Provide urlresolver functions that return fully qualified URLs or view names
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
from django.core.urlresolvers import reverse as django_reverse
|
||||
from django.core.urlresolvers import NoReverseMatch
|
||||
|
||||
from django.utils import six
|
||||
from django.utils.functional import lazy
|
||||
from django.core.urlresolvers import NoReverseMatch, reverse as django_reverse
|
||||
|
||||
|
||||
def reverse(viewname, args=None, kwargs=None, request=None, format=None, **extra):
|
||||
|
|
|
@ -17,13 +17,15 @@ from __future__ import unicode_literals
|
|||
|
||||
import itertools
|
||||
from collections import namedtuple
|
||||
|
||||
from django.conf.urls import url
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.core.urlresolvers import NoReverseMatch
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
from rest_framework import views
|
||||
from rest_framework.compat import get_resolver_match, OrderedDict
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.reverse import reverse
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.compat import get_resolver_match, OrderedDict
|
||||
from rest_framework.urlpatterns import format_suffix_patterns
|
||||
|
||||
|
||||
|
|
|
@ -11,29 +11,31 @@ python primitives.
|
|||
response content is handled by parsers and renderers.
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import warnings
|
||||
|
||||
from django.db import models
|
||||
from django.db.models.fields import FieldDoesNotExist, Field as DjangoModelField
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from rest_framework.compat import (
|
||||
postgres_fields,
|
||||
unicode_to_repr,
|
||||
DurationField as ModelDurationField,
|
||||
from django.db.models.fields import (
|
||||
FieldDoesNotExist, Field as DjangoModelField
|
||||
)
|
||||
|
||||
from rest_framework.utils import model_meta
|
||||
from rest_framework.utils.field_mapping import (
|
||||
get_url_kwargs, get_field_kwargs,
|
||||
get_relation_kwargs, get_nested_relation_kwargs,
|
||||
ClassLookupDict
|
||||
from rest_framework.compat import (
|
||||
postgres_fields, unicode_to_repr, DurationField as ModelDurationField,
|
||||
)
|
||||
from rest_framework.utils.serializer_helpers import (
|
||||
ReturnDict, ReturnList, BoundField, NestedBoundField, BindingDict
|
||||
)
|
||||
from rest_framework.utils.field_mapping import (
|
||||
get_url_kwargs, get_field_kwargs, get_relation_kwargs,
|
||||
get_nested_relation_kwargs, ClassLookupDict
|
||||
)
|
||||
from rest_framework.validators import (
|
||||
UniqueForDateValidator, UniqueForMonthValidator, UniqueForYearValidator,
|
||||
UniqueTogetherValidator
|
||||
)
|
||||
import warnings
|
||||
|
||||
|
||||
# Note: We do the following so that users of the framework can use this style:
|
||||
|
|
|
@ -18,12 +18,15 @@ REST framework settings, checking for user settings first, then falling
|
|||
back to the defaults.
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
from django.test.signals import setting_changed
|
||||
from django.conf import settings
|
||||
|
||||
from django.utils import six
|
||||
from django.conf import settings
|
||||
from django.test.signals import setting_changed
|
||||
|
||||
from rest_framework import ISO_8601
|
||||
from rest_framework.compat import importlib
|
||||
|
||||
|
||||
USER_SETTINGS = getattr(settings, 'REST_FRAMEWORK', None)
|
||||
|
||||
DEFAULTS = {
|
||||
|
|
|
@ -1,14 +1,18 @@
|
|||
from __future__ import unicode_literals, absolute_import
|
||||
|
||||
import re
|
||||
|
||||
from django import template
|
||||
from django.core.urlresolvers import reverse, NoReverseMatch
|
||||
from django.utils import six
|
||||
from django.utils.encoding import iri_to_uri, force_text
|
||||
from django.utils.html import escape
|
||||
from django.utils.safestring import SafeData, mark_safe
|
||||
from django.utils.html import smart_urlquote
|
||||
from django.utils.safestring import SafeData, mark_safe
|
||||
from django.utils.encoding import iri_to_uri, force_text
|
||||
from django.core.urlresolvers import reverse, NoReverseMatch
|
||||
|
||||
from rest_framework.renderers import HTMLFormRenderer
|
||||
from rest_framework.utils.urls import replace_query_param
|
||||
import re
|
||||
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
|
|
@ -3,16 +3,18 @@
|
|||
# Note that we import as `DjangoRequestFactory` and `DjangoClient` in order
|
||||
# to make it harder for the user to import the wrong thing without realizing.
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django
|
||||
from django.conf import settings
|
||||
from django.test.client import Client as DjangoClient
|
||||
from django.test.client import ClientHandler
|
||||
from django.test import testcases
|
||||
from django.utils import six
|
||||
from django.conf import settings
|
||||
from django.test import testcases
|
||||
from django.utils.http import urlencode
|
||||
from django.test.client import ClientHandler, Client as DjangoClient
|
||||
|
||||
from rest_framework.settings import api_settings
|
||||
from rest_framework.compat import RequestFactory as DjangoRequestFactory
|
||||
from rest_framework.compat import force_bytes_or_smart_bytes
|
||||
from rest_framework.compat import (
|
||||
force_bytes_or_smart_bytes, RequestFactory as DjangoRequestFactory
|
||||
)
|
||||
|
||||
|
||||
def force_authenticate(request, user=None, token=None):
|
||||
|
|
|
@ -2,10 +2,13 @@
|
|||
Provides various throttling policies.
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import time
|
||||
|
||||
from django.core.cache import cache as default_cache
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
from rest_framework.settings import api_settings
|
||||
import time
|
||||
|
||||
|
||||
class BaseThrottle(object):
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf.urls import url, include
|
||||
from django.core.urlresolvers import RegexURLResolver
|
||||
|
||||
from rest_framework.settings import api_settings
|
||||
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ The urls must be namespaced as 'rest_framework', and you should make sure
|
|||
your authentication settings include `SessionAuthentication`.
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf.urls import url
|
||||
from django.contrib.auth import views
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from django.core.urlresolvers import resolve, get_script_prefix
|
||||
|
||||
|
||||
|
|
|
@ -2,15 +2,18 @@
|
|||
Helper classes for parsers.
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
from django.db.models.query import QuerySet
|
||||
from django.utils import six, timezone
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.functional import Promise
|
||||
from rest_framework.compat import total_seconds
|
||||
import datetime
|
||||
import decimal
|
||||
import json
|
||||
|
||||
import uuid
|
||||
import json
|
||||
import decimal
|
||||
import datetime
|
||||
|
||||
from django.utils import six, timezone
|
||||
from django.db.models.query import QuerySet
|
||||
from django.utils.functional import Promise
|
||||
from django.utils.encoding import force_text
|
||||
|
||||
from rest_framework.compat import total_seconds
|
||||
|
||||
|
||||
class JSONEncoder(json.JSONEncoder):
|
||||
|
|
|
@ -2,12 +2,14 @@
|
|||
Helper functions for mapping model fields to a dictionary of default
|
||||
keyword arguments that should be used for their equivelent serializer fields.
|
||||
"""
|
||||
from django.core import validators
|
||||
import inspect
|
||||
|
||||
from django.db import models
|
||||
from django.core import validators
|
||||
from django.utils.text import capfirst
|
||||
|
||||
from rest_framework.compat import clean_manytomany_helptext
|
||||
from rest_framework.validators import UniqueValidator
|
||||
import inspect
|
||||
|
||||
|
||||
NUMERIC_FIELD_TYPES = (
|
||||
|
|
|
@ -2,10 +2,13 @@
|
|||
Utility functions to return a formatted name and description for a given view.
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import re
|
||||
|
||||
from django.utils.html import escape
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from rest_framework.compat import apply_markdown, force_text
|
||||
import re
|
||||
|
||||
|
||||
def remove_trailing_string(content, trailing):
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
Helpers for dealing with HTML input.
|
||||
"""
|
||||
import re
|
||||
|
||||
from django.utils.datastructures import MultiValueDict
|
||||
|
||||
|
||||
|
|
|
@ -4,8 +4,10 @@ Handling of media types, as found in HTTP Content-Type and Accept headers.
|
|||
See http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.http.multipartparser import parse_header
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
|
||||
from rest_framework import HTTP_HEADER_ENCODING
|
||||
|
||||
|
||||
|
|
|
@ -5,12 +5,14 @@ relationships and their associated metadata.
|
|||
|
||||
Usage: `get_field_info(model)` returns a `FieldInfo` instance.
|
||||
"""
|
||||
from collections import namedtuple
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.db import models
|
||||
from django.utils import six
|
||||
from rest_framework.compat import OrderedDict
|
||||
import inspect
|
||||
from collections import namedtuple
|
||||
|
||||
from django.utils import six
|
||||
from django.db import models
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
from rest_framework.compat import OrderedDict
|
||||
|
||||
|
||||
FieldInfo = namedtuple('FieldResult', [
|
||||
|
|
|
@ -3,12 +3,15 @@ Helper functions for creating user-friendly representations
|
|||
of serializer classes and serializer fields.
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
from django.db import models
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.functional import Promise
|
||||
from rest_framework.compat import unicode_repr
|
||||
|
||||
import re
|
||||
|
||||
from django.db import models
|
||||
from django.utils.functional import Promise
|
||||
from django.utils.encoding import force_text
|
||||
|
||||
from rest_framework.compat import unicode_repr
|
||||
|
||||
|
||||
def manager_repr(value):
|
||||
model = value.model
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import collections
|
||||
|
||||
from rest_framework.compat import OrderedDict, unicode_to_repr
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,9 @@ object creation, and makes it possible to switch between using the implicit
|
|||
`ModelSerializer` class and an equivalent explicit `Serializer` class.
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from rest_framework.compat import unicode_to_repr
|
||||
from rest_framework.exceptions import ValidationError
|
||||
from rest_framework.utils.representation import smart_repr
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
# coding: utf-8
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import re
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from rest_framework import exceptions
|
||||
from rest_framework.compat import unicode_http_header
|
||||
from rest_framework.reverse import _reverse
|
||||
from rest_framework.settings import api_settings
|
||||
from rest_framework.templatetags.rest_framework import replace_query_param
|
||||
from rest_framework.compat import unicode_http_header
|
||||
from rest_framework.utils.mediatypes import _MediaType
|
||||
import re
|
||||
from rest_framework.templatetags.rest_framework import replace_query_param
|
||||
|
||||
|
||||
class BaseVersioning(object):
|
||||
|
|
|
@ -2,21 +2,24 @@
|
|||
Provides an APIView class that is the base of all views in REST framework.
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.http import Http404
|
||||
from django.utils import six
|
||||
from django.utils.encoding import smart_text
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from rest_framework import status, exceptions
|
||||
from rest_framework.compat import HttpResponseBase, View, set_rollback
|
||||
from rest_framework.request import Request
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.settings import api_settings
|
||||
from rest_framework.utils import formatting
|
||||
|
||||
import inspect
|
||||
import warnings
|
||||
|
||||
from django.utils import six
|
||||
from django.http import Http404
|
||||
from django.utils.encoding import smart_text
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from rest_framework import status, exceptions
|
||||
from rest_framework.request import Request
|
||||
from rest_framework.utils import formatting
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.settings import api_settings
|
||||
from rest_framework.compat import HttpResponseBase, View, set_rollback
|
||||
|
||||
|
||||
def get_view_name(view_cls, suffix=None):
|
||||
"""
|
||||
|
|
|
@ -19,8 +19,10 @@ automatically.
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from functools import update_wrapper
|
||||
|
||||
from django.utils.decorators import classonlymethod
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
||||
from rest_framework import views, generics, mixins
|
||||
|
||||
|
||||
|
|
4
setup.py
4
setup.py
|
@ -1,11 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from setuptools import setup
|
||||
from setuptools.command.test import test as TestCommand
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
from setuptools import setup
|
||||
|
||||
|
||||
def get_version(package):
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user