mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 09:36:49 +03:00
Drop Django 1.10 support (#5657)
* Remove Django 1.10 from CI * Remove Django 1.10 compat code
This commit is contained in:
parent
9b8af04e7f
commit
a628a2dbce
|
@ -9,7 +9,6 @@ python:
|
||||||
sudo: false
|
sudo: false
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- DJANGO=1.10
|
|
||||||
- DJANGO=1.11
|
- DJANGO=1.11
|
||||||
- DJANGO=2.0
|
- DJANGO=2.0
|
||||||
- DJANGO=2.1
|
- DJANGO=2.1
|
||||||
|
|
|
@ -53,7 +53,7 @@ There is a live example API for testing purposes, [available here][sandbox].
|
||||||
# Requirements
|
# Requirements
|
||||||
|
|
||||||
* Python (2.7, 3.4, 3.5, 3.6)
|
* Python (2.7, 3.4, 3.5, 3.6)
|
||||||
* Django (1.10, 1.11, 2.0)
|
* Django (1.11, 2.0)
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ continued development by **[signing up for a paid plan][funding]**.
|
||||||
REST framework requires the following:
|
REST framework requires the following:
|
||||||
|
|
||||||
* Python (2.7, 3.4, 3.5, 3.6)
|
* Python (2.7, 3.4, 3.5, 3.6)
|
||||||
* Django (1.10, 1.11, 2.0)
|
* Django (1.11, 2.0)
|
||||||
|
|
||||||
The following packages are optional:
|
The following packages are optional:
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
# Optional packages which may be used with REST framework.
|
# Optional packages which may be used with REST framework.
|
||||||
pytz==2017.2
|
|
||||||
psycopg2-binary==2.7.4
|
psycopg2-binary==2.7.4
|
||||||
markdown==2.6.4
|
markdown==2.6.4
|
||||||
django-guardian==1.4.9
|
django-guardian==1.4.9
|
||||||
|
|
|
@ -6,13 +6,12 @@ from __future__ import unicode_literals
|
||||||
import base64
|
import base64
|
||||||
import binascii
|
import binascii
|
||||||
|
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import authenticate, get_user_model
|
||||||
from django.middleware.csrf import CsrfViewMiddleware
|
from django.middleware.csrf import CsrfViewMiddleware
|
||||||
from django.utils.six import text_type
|
from django.utils.six import text_type
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from rest_framework import HTTP_HEADER_ENCODING, exceptions
|
from rest_framework import HTTP_HEADER_ENCODING, exceptions
|
||||||
from rest_framework.compat import authenticate
|
|
||||||
|
|
||||||
|
|
||||||
def get_authorization_header(request):
|
def get_authorization_header(request):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
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 serializers
|
from rest_framework import serializers
|
||||||
from rest_framework.compat import authenticate
|
|
||||||
|
|
||||||
|
|
||||||
class AuthTokenSerializer(serializers.Serializer):
|
class AuthTokenSerializer(serializers.Serializer):
|
||||||
|
|
|
@ -5,7 +5,6 @@ versions of Django/Python, and compatibility wrappers around optional packages.
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import django
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core import validators
|
from django.core import validators
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
|
@ -242,12 +241,6 @@ else:
|
||||||
def md_filter_add_syntax_highlight(md):
|
def md_filter_add_syntax_highlight(md):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# pytz is required from Django 1.11. Remove when dropping Django 1.10 support.
|
|
||||||
try:
|
|
||||||
import pytz # noqa
|
|
||||||
from pytz.exceptions import InvalidTimeError
|
|
||||||
except ImportError:
|
|
||||||
InvalidTimeError = Exception
|
|
||||||
|
|
||||||
# Django 1.x url routing syntax. Remove when dropping Django 1.11 support.
|
# Django 1.x url routing syntax. Remove when dropping Django 1.11 support.
|
||||||
try:
|
try:
|
||||||
|
@ -298,11 +291,3 @@ class MinLengthValidator(CustomValidatorMessage, validators.MinLengthValidator):
|
||||||
|
|
||||||
class MaxLengthValidator(CustomValidatorMessage, validators.MaxLengthValidator):
|
class MaxLengthValidator(CustomValidatorMessage, validators.MaxLengthValidator):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def authenticate(request=None, **credentials):
|
|
||||||
from django.contrib.auth import authenticate
|
|
||||||
if django.VERSION < (1, 11):
|
|
||||||
return authenticate(**credentials)
|
|
||||||
else:
|
|
||||||
return authenticate(request=request, **credentials)
|
|
||||||
|
|
|
@ -29,11 +29,12 @@ from django.utils.functional import lazy
|
||||||
from django.utils.ipv6 import clean_ipv6_address
|
from django.utils.ipv6 import clean_ipv6_address
|
||||||
from django.utils.timezone import utc
|
from django.utils.timezone import utc
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
from pytz.exceptions import InvalidTimeError
|
||||||
|
|
||||||
from rest_framework import ISO_8601
|
from rest_framework import ISO_8601
|
||||||
from rest_framework.compat import (
|
from rest_framework.compat import (
|
||||||
InvalidTimeError, MaxLengthValidator, MaxValueValidator,
|
MaxLengthValidator, MaxValueValidator, MinLengthValidator,
|
||||||
MinLengthValidator, MinValueValidator, unicode_repr, unicode_to_repr
|
MinValueValidator, unicode_repr, unicode_to_repr
|
||||||
)
|
)
|
||||||
from rest_framework.exceptions import ErrorDetail, ValidationError
|
from rest_framework.exceptions import ErrorDetail, ValidationError
|
||||||
from rest_framework.settings import api_settings
|
from rest_framework.settings import api_settings
|
||||||
|
|
|
@ -13,22 +13,11 @@ You should make sure your authentication settings include `SessionAuthentication
|
||||||
"""
|
"""
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import django
|
|
||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
from django.contrib.auth import views
|
from django.contrib.auth import views
|
||||||
|
|
||||||
if django.VERSION < (1, 11):
|
|
||||||
login = views.login
|
|
||||||
login_kwargs = {'template_name': 'rest_framework/login.html'}
|
|
||||||
logout = views.logout
|
|
||||||
else:
|
|
||||||
login = views.LoginView.as_view(template_name='rest_framework/login.html')
|
|
||||||
login_kwargs = {}
|
|
||||||
logout = views.LogoutView.as_view()
|
|
||||||
|
|
||||||
|
|
||||||
app_name = 'rest_framework'
|
app_name = 'rest_framework'
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^login/$', login, login_kwargs, name='login'),
|
url(r'^login/$', views.LoginView.as_view(template_name='rest_framework/login.html'), name='login'),
|
||||||
url(r'^logout/$', logout, name='logout'),
|
url(r'^logout/$', views.LogoutView.as_view(), name='logout'),
|
||||||
]
|
]
|
||||||
|
|
|
@ -17,7 +17,7 @@ skip=.tox
|
||||||
atomic=true
|
atomic=true
|
||||||
multi_line_output=5
|
multi_line_output=5
|
||||||
known_standard_library=types
|
known_standard_library=types
|
||||||
known_third_party=pytest,_pytest,django
|
known_third_party=pytest,_pytest,django,pytz
|
||||||
known_first_party=rest_framework
|
known_first_party=rest_framework
|
||||||
|
|
||||||
[coverage:run]
|
[coverage:run]
|
||||||
|
|
1
setup.py
1
setup.py
|
@ -58,7 +58,6 @@ setup(
|
||||||
'Development Status :: 5 - Production/Stable',
|
'Development Status :: 5 - Production/Stable',
|
||||||
'Environment :: Web Environment',
|
'Environment :: Web Environment',
|
||||||
'Framework :: Django',
|
'Framework :: Django',
|
||||||
'Framework :: Django :: 1.10',
|
|
||||||
'Framework :: Django :: 1.11',
|
'Framework :: Django :: 1.11',
|
||||||
'Framework :: Django :: 2.0',
|
'Framework :: Django :: 2.0',
|
||||||
'Intended Audience :: Developers',
|
'Intended Audience :: Developers',
|
||||||
|
|
|
@ -6,6 +6,7 @@ import uuid
|
||||||
from decimal import ROUND_DOWN, ROUND_UP, Decimal
|
from decimal import ROUND_DOWN, ROUND_UP, Decimal
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
import pytz
|
||||||
from django.core.exceptions import ValidationError as DjangoValidationError
|
from django.core.exceptions import ValidationError as DjangoValidationError
|
||||||
from django.http import QueryDict
|
from django.http import QueryDict
|
||||||
from django.test import TestCase, override_settings
|
from django.test import TestCase, override_settings
|
||||||
|
@ -13,14 +14,9 @@ from django.utils import six
|
||||||
from django.utils.timezone import activate, deactivate, override, utc
|
from django.utils.timezone import activate, deactivate, override, utc
|
||||||
|
|
||||||
import rest_framework
|
import rest_framework
|
||||||
from rest_framework import compat, exceptions, serializers
|
from rest_framework import exceptions, serializers
|
||||||
from rest_framework.fields import DjangoImageField, is_simple_callable
|
from rest_framework.fields import DjangoImageField, is_simple_callable
|
||||||
|
|
||||||
try:
|
|
||||||
import pytz
|
|
||||||
except ImportError:
|
|
||||||
pytz = None
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import typings
|
import typings
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -1309,7 +1305,6 @@ class TestNaiveDateTimeField(FieldValues):
|
||||||
field = serializers.DateTimeField(default_timezone=None)
|
field = serializers.DateTimeField(default_timezone=None)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(pytz is None, reason='pytz not installed')
|
|
||||||
class TestTZWithDateTimeField(FieldValues):
|
class TestTZWithDateTimeField(FieldValues):
|
||||||
"""
|
"""
|
||||||
Valid and invalid values for `DateTimeField` when not using UTC as the timezone.
|
Valid and invalid values for `DateTimeField` when not using UTC as the timezone.
|
||||||
|
@ -1332,7 +1327,6 @@ class TestTZWithDateTimeField(FieldValues):
|
||||||
cls.field = serializers.DateTimeField(default_timezone=kolkata)
|
cls.field = serializers.DateTimeField(default_timezone=kolkata)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(pytz is None, reason='pytz not installed')
|
|
||||||
@override_settings(TIME_ZONE='UTC', USE_TZ=True)
|
@override_settings(TIME_ZONE='UTC', USE_TZ=True)
|
||||||
class TestDefaultTZDateTimeField(TestCase):
|
class TestDefaultTZDateTimeField(TestCase):
|
||||||
"""
|
"""
|
||||||
|
@ -1392,7 +1386,7 @@ class TestNaiveDayLightSavingTimeTimeZoneDateTimeField(FieldValues):
|
||||||
class MockTimezone:
|
class MockTimezone:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def localize(value, is_dst):
|
def localize(value, is_dst):
|
||||||
raise compat.InvalidTimeError()
|
raise pytz.InvalidTimeError()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return 'America/New_York'
|
return 'America/New_York'
|
||||||
|
|
3
tox.ini
3
tox.ini
|
@ -1,6 +1,5 @@
|
||||||
[tox]
|
[tox]
|
||||||
envlist =
|
envlist =
|
||||||
{py27,py34,py35}-django110,
|
|
||||||
{py27,py34,py35,py36}-django111,
|
{py27,py34,py35,py36}-django111,
|
||||||
{py34,py35,py36}-django20,
|
{py34,py35,py36}-django20,
|
||||||
{py35,py36}-django21
|
{py35,py36}-django21
|
||||||
|
@ -9,7 +8,6 @@ envlist =
|
||||||
|
|
||||||
[travis:env]
|
[travis:env]
|
||||||
DJANGO =
|
DJANGO =
|
||||||
1.10: django110
|
|
||||||
1.11: django111
|
1.11: django111
|
||||||
2.0: django20
|
2.0: django20
|
||||||
2.1: django21
|
2.1: django21
|
||||||
|
@ -22,7 +20,6 @@ setenv =
|
||||||
PYTHONDONTWRITEBYTECODE=1
|
PYTHONDONTWRITEBYTECODE=1
|
||||||
PYTHONWARNINGS=once
|
PYTHONWARNINGS=once
|
||||||
deps =
|
deps =
|
||||||
django110: Django>=1.10,<1.11
|
|
||||||
django111: Django>=1.11,<2.0
|
django111: Django>=1.11,<2.0
|
||||||
django20: Django>=2.0,<2.1
|
django20: Django>=2.0,<2.1
|
||||||
django21: Django>=2.1b1,<2.2
|
django21: Django>=2.1b1,<2.2
|
||||||
|
|
Loading…
Reference in New Issue
Block a user