Skip to content

Commit

Permalink
Remove support for Django 1.8, 1.9, and 1.10 (#377)
Browse files Browse the repository at this point in the history
* `HISTORY.rst` - add note
* `README.rst` - update list of tested versions
* `tox.ini` - update test grid
* `setup.py` - specify Django version in `install_requires`, remove classifiers
* Remove `compat` module and always import `MiddlewareMixin`, update code to always use `MIDDLEWARE` instead of `MIDDLEWARE_CLASSES`
  • Loading branch information
adamchainz authored Mar 5, 2019
1 parent 428b333 commit 6a28e29
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 48 deletions.
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Pending

.. Insert new release notes below this line
* Drop Django 1.8, 1.9, and 1.10 support. Only Django 1.11+ is supported now.

2.4.1 (2019-02-28)
------------------

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Requirements
Tested with all combinations of:

* Python: 2.7, 3.6
* Django: 1.8, 1.9, 1.10, 1.11, 2.0, 2.1
* Django: 1.11, 2.0, 2.1

Setup
-----
Expand Down
8 changes: 0 additions & 8 deletions corsheaders/compat.py

This file was deleted.

2 changes: 1 addition & 1 deletion corsheaders/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from django import http
from django.apps import apps
from django.utils.cache import patch_vary_headers
from django.utils.deprecation import MiddlewareMixin
from django.utils.six.moves.urllib.parse import urlparse

from .compat import MiddlewareMixin
from .conf import conf
from .signals import check_request_enabled

Expand Down
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,14 @@ def get_version(filename):
packages=['corsheaders'],
license='MIT License',
keywords=['django', 'cors', 'middleware', 'rest', 'api'],
install_requires=[],
install_requires=[
'Django>=1.11',
],
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Framework :: Django',
'Framework :: Django :: 1.8',
'Framework :: Django :: 1.9',
'Framework :: Django :: 1.10',
'Framework :: Django :: 1.11',
'Framework :: Django :: 2.0',
'Framework :: Django :: 2.1',
Expand Down
17 changes: 3 additions & 14 deletions tests/settings.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from __future__ import absolute_import

import django
from django.conf import global_settings

SECRET_KEY = 'NOTASECRET'

ALLOWED_HOSTS = ['*']
Expand All @@ -26,16 +23,8 @@

ROOT_URLCONF = 'tests.urls'

if django.VERSION >= (2, 0):
middlewares = list(global_settings.MIDDLEWARE)
else:
middlewares = list(global_settings.MIDDLEWARE_CLASSES)

middlewares.append('corsheaders.middleware.CorsMiddleware')

if django.VERSION >= (1, 10):
MIDDLEWARE = middlewares
else:
MIDDLEWARE_CLASSES = middlewares
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
]

SECURE_PROXY_SSL_HEADER = ('HTTP_FAKE_SECURE', 'true')
12 changes: 3 additions & 9 deletions tests/test_middleware.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from __future__ import absolute_import

import django
from django.http import HttpResponse
from django.test import TestCase
from django.test.utils import override_settings
from django.utils.deprecation import MiddlewareMixin

from corsheaders.compat import MiddlewareMixin
from corsheaders.middleware import (
ACCESS_CONTROL_ALLOW_CREDENTIALS, ACCESS_CONTROL_ALLOW_HEADERS, ACCESS_CONTROL_ALLOW_METHODS,
ACCESS_CONTROL_ALLOW_ORIGIN, ACCESS_CONTROL_EXPOSE_HEADERS, ACCESS_CONTROL_MAX_AGE
Expand Down Expand Up @@ -301,15 +300,10 @@ def test_get_short_circuit(self):
Test a scenario when a middleware that returns a response is run before
the ``CorsMiddleware``. In this case
``CorsMiddleware.process_response()`` should ignore the request if
MIDDLEWARE setting is used (new mechanism in Django 1.10+) and process
the request and add CORS response headers if MIDDLEWARE_CLASSES is
used in a backward compatible fashion with django-cors-headers pre 1.3.0.
MIDDLEWARE setting is used (new mechanism in Django 1.10+).
"""
resp = self.client.get('/', HTTP_ORIGIN='http://example.com')
if django.VERSION[:2] >= (1, 10):
assert ACCESS_CONTROL_ALLOW_ORIGIN not in resp
else:
assert ACCESS_CONTROL_ALLOW_ORIGIN in resp
assert ACCESS_CONTROL_ALLOW_ORIGIN not in resp

@override_settings(
CORS_ORIGIN_WHITELIST=['example.com'],
Expand Down
8 changes: 1 addition & 7 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,14 @@

from contextlib import contextmanager

import django
from django.test.utils import modify_settings

from corsheaders.signals import check_request_enabled


def add_middleware(action, path):
if django.VERSION[:2] >= (1, 10):
middleware_setting = 'MIDDLEWARE'
else:
middleware_setting = 'MIDDLEWARE_CLASSES'

return modify_settings(**{
middleware_setting: {
'MIDDLEWARE': {
action: path,
}
})
Expand Down
5 changes: 1 addition & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
envlist =
py{27,3}-django{18,19,110,111},
py{27,3}-django{111},
py3-django{20,21},
py{27,3}-codestyle

Expand All @@ -10,9 +10,6 @@ setenv =
install_command = pip install --no-deps {opts} {packages}
deps =
-rrequirements.txt
django18: Django>=1.8,<1.9
django19: Django>=1.9,<1.10
django110: Django>=1.10,<1.11
django111: Django>=1.11,<2.0
django20: Django>=2.0,<2.1
django21: Django>=2.1,<2.2
Expand Down

0 comments on commit 6a28e29

Please sign in to comment.