From ceb81605688e8f4767ffdce50dd6dc51e4773aa1 Mon Sep 17 00:00:00 2001 From: Matt Layman Date: Sun, 17 Dec 2017 21:50:46 -0500 Subject: [PATCH 1/8] Add DRF 3.7 to the test matrix. Fixes #388 --- .travis.yml | 2 +- CHANGELOG.md | 2 ++ README.rst | 4 ++-- docs/getting-started.md | 4 ++-- tox.ini | 3 ++- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1656f959..e1906ee9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ python: - "3.5" - "3.6" env: - - DJANGO=">=1.11,<1.12" DRF=">=3.6.3,<3.7" + - DJANGO=">=1.11,>=2.0,<2.1" DRF=">=3.6.3,>=3.7.0,<3.8" before_install: # Force an upgrade of py & pytest to avoid VersionConflict - pip install --upgrade py diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a6e0aba..a3daf4a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ v2.4.0 +* Add support for Django REST Framework 3.7.x. +* Add support for Django 2.0. * Drop support for Django 1.8 - 1.10 (EOL) * Drop support for Django REST Framework < 3.6.3 (3.6.3 is the first to support Django 1.11) diff --git a/README.rst b/README.rst index cb9a09dc..30a2ada8 100644 --- a/README.rst +++ b/README.rst @@ -68,8 +68,8 @@ Requirements ------------ 1. Python (2.7, 3.4, 3.5, 3.6) -2. Django (1.11) -3. Django REST Framework (3.6) +2. Django (1.11, 2.0) +3. Django REST Framework (3.6, 3.7) ------------ Installation diff --git a/docs/getting-started.md b/docs/getting-started.md index aac1cfc2..4afcf2df 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -52,8 +52,8 @@ like the following: ## Requirements 1. Python (2.7, 3.4, 3.5, 3.6) -2. Django (1.11) -3. Django REST Framework (3.6) +2. Django (1.11, 2.0) +3. Django REST Framework (3.6, 3.7) ## Installation diff --git a/tox.ini b/tox.ini index 4b08065f..dc7470e0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,12 @@ [tox] envlist = - py{27,34,35,36}-django111-drf{36}, + py{27,34,35,36}-django111-drf{36,37}, [testenv] deps = django111: Django>=1.11,<1.12 drf36: djangorestframework>=3.6.3,<3.7 + drf37: djangorestframework>=3.7.0,<3.8 setenv = PYTHONPATH = {toxinidir} From 27aec70749813e5b7ef746f2b69f0826c481f972 Mon Sep 17 00:00:00 2001 From: Matt Layman Date: Sun, 17 Dec 2017 22:04:19 -0500 Subject: [PATCH 2/8] Switch to an explicit build matrix. --- .travis.yml | 69 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 62 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index e1906ee9..44524ccf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,13 +2,68 @@ language: python sudo: false cache: pip -python: - - "2.7" - - "3.4" - - "3.5" - - "3.6" -env: - - DJANGO=">=1.11,>=2.0,<2.1" DRF=">=3.6.3,>=3.7.0,<3.8" +# Favor explicit over implicit and use an explicit build matrix. +matrix: + include: + - python: 2.7 + env: + - DJANGO: ">=1.11,<2.0" + - DRF: ">=3.6.3,<3.7" + - python: 2.7 + env: + - DJANGO: ">=1.11,<2.0" + - DRF: ">=3.7.0,<3.8" + + - python: 3.4 + env: + - DJANGO: ">=1.11,<2.0" + - DRF: ">=3.6.3,<3.7" + - python: 3.4 + env: + - DJANGO: ">=1.11,<2.0" + - DRF: ">=3.7.0,<3.8" + - python: 3.4 + env: + - DJANGO: ">=2.0,<2.1" + - DRF: ">=3.6.3,<3.7" + - python: 3.4 + env: + - DJANGO: ">=2.0,<2.1" + - DRF: ">=3.7.0,<3.8" + + - python: 3.5 + env: + - DJANGO: ">=1.11,<2.0" + - DRF: ">=3.6.3,<3.7" + - python: 3.5 + env: + - DJANGO: ">=1.11,<2.0" + - DRF: ">=3.7.0,<3.8" + - python: 3.5 + env: + - DJANGO: ">=2.0,<2.1" + - DRF: ">=3.6.3,<3.7" + - python: 3.5 + env: + - DJANGO: ">=2.0,<2.1" + - DRF: ">=3.7.0,<3.8" + + - python: 3.6 + env: + - DJANGO: ">=1.11,<2.0" + - DRF: ">=3.6.3,<3.7" + - python: 3.6 + env: + - DJANGO: ">=1.11,<2.0" + - DRF: ">=3.7.0,<3.8" + - python: 3.6 + env: + - DJANGO: ">=2.0,<2.1" + - DRF: ">=3.6.3,<3.7" + - python: 3.6 + env: + - DJANGO: ">=2.0,<2.1" + - DRF: ">=3.7.0,<3.8" before_install: # Force an upgrade of py & pytest to avoid VersionConflict - pip install --upgrade py From 1bdf12614d485c2cfbb3c59c9fa1d53f482a3e47 Mon Sep 17 00:00:00 2001 From: Matt Layman Date: Sun, 17 Dec 2017 22:13:29 -0500 Subject: [PATCH 3/8] Change env format. Without the equals sign, Travis will drop the double quotes and screw up the environment variable export. --- .travis.yml | 56 ++++++++++++++--------------------------------------- 1 file changed, 14 insertions(+), 42 deletions(-) diff --git a/.travis.yml b/.travis.yml index 44524ccf..52c9d164 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,64 +6,36 @@ cache: pip matrix: include: - python: 2.7 - env: - - DJANGO: ">=1.11,<2.0" - - DRF: ">=3.6.3,<3.7" + env: DJANGO=">=1.11,<2.0" DRF=">=3.6.3,<3.7" - python: 2.7 - env: - - DJANGO: ">=1.11,<2.0" - - DRF: ">=3.7.0,<3.8" + env: DJANGO=">=1.11,<2.0" DRF=">=3.7.0,<3.8" - python: 3.4 - env: - - DJANGO: ">=1.11,<2.0" - - DRF: ">=3.6.3,<3.7" + env: DJANGO=">=1.11,<2.0" DRF=">=3.6.3,<3.7" - python: 3.4 - env: - - DJANGO: ">=1.11,<2.0" - - DRF: ">=3.7.0,<3.8" + env: DJANGO=">=1.11,<2.0" DRF=">=3.7.0,<3.8" - python: 3.4 - env: - - DJANGO: ">=2.0,<2.1" - - DRF: ">=3.6.3,<3.7" + env: DJANGO=">=2.0,<2.1" DRF=">=3.6.3,<3.7" - python: 3.4 - env: - - DJANGO: ">=2.0,<2.1" - - DRF: ">=3.7.0,<3.8" + env: DJANGO=">=2.0,<2.1" DRF=">=3.7.0,<3.8" - python: 3.5 - env: - - DJANGO: ">=1.11,<2.0" - - DRF: ">=3.6.3,<3.7" + env: DJANGO=">=1.11,<2.0" DRF=">=3.6.3,<3.7" - python: 3.5 - env: - - DJANGO: ">=1.11,<2.0" - - DRF: ">=3.7.0,<3.8" + env: DJANGO=">=1.11,<2.0" DRF=">=3.7.0,<3.8" - python: 3.5 - env: - - DJANGO: ">=2.0,<2.1" - - DRF: ">=3.6.3,<3.7" + env: DJANGO=">=2.0,<2.1" DRF=">=3.6.3,<3.7" - python: 3.5 - env: - - DJANGO: ">=2.0,<2.1" - - DRF: ">=3.7.0,<3.8" + env: DJANGO=">=2.0,<2.1" DRF=">=3.7.0,<3.8" - python: 3.6 - env: - - DJANGO: ">=1.11,<2.0" - - DRF: ">=3.6.3,<3.7" + env: DJANGO=">=1.11,<2.0" DRF=">=3.6.3,<3.7" - python: 3.6 - env: - - DJANGO: ">=1.11,<2.0" - - DRF: ">=3.7.0,<3.8" + env: DJANGO=">=1.11,<2.0" DRF=">=3.7.0,<3.8" - python: 3.6 - env: - - DJANGO: ">=2.0,<2.1" - - DRF: ">=3.6.3,<3.7" + env: DJANGO=">=2.0,<2.1" DRF=">=3.6.3,<3.7" - python: 3.6 - env: - - DJANGO: ">=2.0,<2.1" - - DRF: ">=3.7.0,<3.8" + env: DJANGO=">=2.0,<2.1" DRF=">=3.7.0,<3.8" before_install: # Force an upgrade of py & pytest to avoid VersionConflict - pip install --upgrade py From bacec526e2a4a0e4a939e33107cbd947a3928312 Mon Sep 17 00:00:00 2001 From: Matt Layman Date: Sun, 17 Dec 2017 22:18:28 -0500 Subject: [PATCH 4/8] DRF 3.6.x does not support Django 2.0. --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 52c9d164..fce5e4bd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,6 @@ matrix: env: DJANGO=">=1.11,<2.0" DRF=">=3.6.3,<3.7" - python: 3.4 env: DJANGO=">=1.11,<2.0" DRF=">=3.7.0,<3.8" - - python: 3.4 - env: DJANGO=">=2.0,<2.1" DRF=">=3.6.3,<3.7" - python: 3.4 env: DJANGO=">=2.0,<2.1" DRF=">=3.7.0,<3.8" @@ -23,8 +21,6 @@ matrix: env: DJANGO=">=1.11,<2.0" DRF=">=3.6.3,<3.7" - python: 3.5 env: DJANGO=">=1.11,<2.0" DRF=">=3.7.0,<3.8" - - python: 3.5 - env: DJANGO=">=2.0,<2.1" DRF=">=3.6.3,<3.7" - python: 3.5 env: DJANGO=">=2.0,<2.1" DRF=">=3.7.0,<3.8" @@ -32,8 +28,6 @@ matrix: env: DJANGO=">=1.11,<2.0" DRF=">=3.6.3,<3.7" - python: 3.6 env: DJANGO=">=1.11,<2.0" DRF=">=3.7.0,<3.8" - - python: 3.6 - env: DJANGO=">=2.0,<2.1" DRF=">=3.6.3,<3.7" - python: 3.6 env: DJANGO=">=2.0,<2.1" DRF=">=3.7.0,<3.8" before_install: From c4190a2d2ecc1396cd8e68fa660968d697dacf3c Mon Sep 17 00:00:00 2001 From: Matt Layman Date: Sun, 17 Dec 2017 22:23:21 -0500 Subject: [PATCH 5/8] Add required on_delete to ForeignKey fields. --- example/models.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/example/models.py b/example/models.py index 5395607f..21af8736 100644 --- a/example/models.py +++ b/example/models.py @@ -60,7 +60,7 @@ class Meta: class Author(BaseModel): name = models.CharField(max_length=50) email = models.EmailField() - type = models.ForeignKey(AuthorType, null=True) + type = models.ForeignKey(AuthorType, null=True, on_delete=models.CASCADE) def __str__(self): return self.name @@ -83,7 +83,7 @@ class Meta: @python_2_unicode_compatible class Entry(BaseModel): - blog = models.ForeignKey(Blog) + blog = models.ForeignKey(Blog, on_delete=models.CASCADE) headline = models.CharField(max_length=255) body_text = models.TextField(null=True) pub_date = models.DateField(null=True) @@ -103,12 +103,13 @@ class Meta: @python_2_unicode_compatible class Comment(BaseModel): - entry = models.ForeignKey(Entry, related_name='comments') + entry = models.ForeignKey(Entry, related_name='comments', on_delete=models.CASCADE) body = models.TextField() author = models.ForeignKey( Author, null=True, - blank=True + blank=True, + on_delete=models.CASCADE, ) def __str__(self): @@ -133,7 +134,8 @@ class ResearchProject(Project): @python_2_unicode_compatible class Company(models.Model): name = models.CharField(max_length=100) - current_project = models.ForeignKey(Project, related_name='companies') + current_project = models.ForeignKey( + Project, related_name='companies', on_delete=models.CASCADE) future_projects = models.ManyToManyField(Project) def __str__(self): From 7ae166fa8ee23835ee6f7bdf9ad22d8c1b1c8512 Mon Sep 17 00:00:00 2001 From: Matt Layman Date: Sun, 17 Dec 2017 22:27:37 -0500 Subject: [PATCH 6/8] Add on_delete to OneToOneField. --- example/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/models.py b/example/models.py index 21af8736..d94219f3 100644 --- a/example/models.py +++ b/example/models.py @@ -71,7 +71,7 @@ class Meta: @python_2_unicode_compatible class AuthorBio(BaseModel): - author = models.OneToOneField(Author, related_name='bio') + author = models.OneToOneField(Author, related_name='bio', on_delete=models.CASCADE) body = models.TextField() def __str__(self): From 511eb02ffd2fe49d60538059d74c6c17ce4a48c8 Mon Sep 17 00:00:00 2001 From: Matt Layman Date: Sun, 17 Dec 2017 22:37:30 -0500 Subject: [PATCH 7/8] Switch core.urlresolvers to urls for Django 2.0 compatibility. --- example/tests/integration/test_includes.py | 2 +- example/tests/integration/test_meta.py | 2 +- example/tests/integration/test_model_resource_name.py | 2 +- example/tests/integration/test_non_paginated_responses.py | 2 +- example/tests/integration/test_pagination.py | 2 +- example/tests/integration/test_polymorphism.py | 2 +- example/tests/integration/test_sparse_fieldsets.py | 2 +- example/tests/test_format_keys.py | 2 +- example/tests/test_generic_validation.py | 2 +- example/tests/test_generic_viewset.py | 2 +- example/tests/test_model_viewsets.py | 2 +- example/tests/test_multiple_id_mixin.py | 2 +- example/tests/test_serializers.py | 2 +- example/tests/test_sideload_resources.py | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/example/tests/integration/test_includes.py b/example/tests/integration/test_includes.py index a75310bc..15c0e0eb 100644 --- a/example/tests/integration/test_includes.py +++ b/example/tests/integration/test_includes.py @@ -1,5 +1,5 @@ import pytest -from django.core.urlresolvers import reverse +from django.urls import reverse from example.tests.utils import load_json diff --git a/example/tests/integration/test_meta.py b/example/tests/integration/test_meta.py index f41f6683..e93b79a2 100644 --- a/example/tests/integration/test_meta.py +++ b/example/tests/integration/test_meta.py @@ -1,7 +1,7 @@ from datetime import datetime import pytest -from django.core.urlresolvers import reverse +from django.urls import reverse from example.tests.utils import load_json diff --git a/example/tests/integration/test_model_resource_name.py b/example/tests/integration/test_model_resource_name.py index 035ad449..1ca28966 100644 --- a/example/tests/integration/test_model_resource_name.py +++ b/example/tests/integration/test_model_resource_name.py @@ -1,7 +1,7 @@ from copy import deepcopy import pytest -from django.core.urlresolvers import reverse +from django.urls import reverse from rest_framework import status from example import models, serializers, views diff --git a/example/tests/integration/test_non_paginated_responses.py b/example/tests/integration/test_non_paginated_responses.py index 2425d93b..e28a5441 100644 --- a/example/tests/integration/test_non_paginated_responses.py +++ b/example/tests/integration/test_non_paginated_responses.py @@ -1,5 +1,5 @@ import pytest -from django.core.urlresolvers import reverse +from django.urls import reverse from rest_framework_json_api.pagination import PageNumberPagination diff --git a/example/tests/integration/test_pagination.py b/example/tests/integration/test_pagination.py index 9e74f7d3..ee725cf9 100644 --- a/example/tests/integration/test_pagination.py +++ b/example/tests/integration/test_pagination.py @@ -1,5 +1,5 @@ import pytest -from django.core.urlresolvers import reverse +from django.urls import reverse from example.tests.utils import load_json diff --git a/example/tests/integration/test_polymorphism.py b/example/tests/integration/test_polymorphism.py index 2aa2091b..ab8638cb 100644 --- a/example/tests/integration/test_polymorphism.py +++ b/example/tests/integration/test_polymorphism.py @@ -2,7 +2,7 @@ import random import pytest -from django.core.urlresolvers import reverse +from django.urls import reverse from example.tests.utils import load_json diff --git a/example/tests/integration/test_sparse_fieldsets.py b/example/tests/integration/test_sparse_fieldsets.py index ffdba796..c76f1efd 100644 --- a/example/tests/integration/test_sparse_fieldsets.py +++ b/example/tests/integration/test_sparse_fieldsets.py @@ -1,5 +1,5 @@ import pytest -from django.core.urlresolvers import reverse +from django.urls import reverse pytestmark = pytest.mark.django_db diff --git a/example/tests/test_format_keys.py b/example/tests/test_format_keys.py index 17993336..f08b522b 100644 --- a/example/tests/test_format_keys.py +++ b/example/tests/test_format_keys.py @@ -1,5 +1,5 @@ from django.contrib.auth import get_user_model -from django.core.urlresolvers import reverse +from django.urls import reverse from django.utils import encoding from example.tests import TestBase diff --git a/example/tests/test_generic_validation.py b/example/tests/test_generic_validation.py index 8591ea28..6e96dbdf 100644 --- a/example/tests/test_generic_validation.py +++ b/example/tests/test_generic_validation.py @@ -1,4 +1,4 @@ -from django.core.urlresolvers import reverse +from django.urls import reverse from example.tests import TestBase from example.tests.utils import load_json diff --git a/example/tests/test_generic_viewset.py b/example/tests/test_generic_viewset.py index 14c65040..3ca49b49 100644 --- a/example/tests/test_generic_viewset.py +++ b/example/tests/test_generic_viewset.py @@ -1,5 +1,5 @@ from django.conf import settings -from django.core.urlresolvers import reverse +from django.urls import reverse from example.tests import TestBase from example.tests.utils import load_json diff --git a/example/tests/test_model_viewsets.py b/example/tests/test_model_viewsets.py index 36949fe1..3b6a19e8 100644 --- a/example/tests/test_model_viewsets.py +++ b/example/tests/test_model_viewsets.py @@ -1,7 +1,7 @@ import pytest from django.conf import settings from django.contrib.auth import get_user_model -from django.core.urlresolvers import reverse +from django.urls import reverse from django.utils import encoding from example.tests import TestBase diff --git a/example/tests/test_multiple_id_mixin.py b/example/tests/test_multiple_id_mixin.py index f3edd171..6ec73ad8 100644 --- a/example/tests/test_multiple_id_mixin.py +++ b/example/tests/test_multiple_id_mixin.py @@ -1,6 +1,6 @@ import json -from django.core.urlresolvers import reverse +from django.urls import reverse from django.utils import encoding from example.tests import TestBase diff --git a/example/tests/test_serializers.py b/example/tests/test_serializers.py index af864650..b8459592 100644 --- a/example/tests/test_serializers.py +++ b/example/tests/test_serializers.py @@ -1,6 +1,6 @@ import pytest -from django.core.urlresolvers import reverse from django.test import TestCase +from django.urls import reverse from django.utils import timezone from rest_framework_json_api.serializers import ResourceIdentifierObjectSerializer diff --git a/example/tests/test_sideload_resources.py b/example/tests/test_sideload_resources.py index b06570c6..4c9c1525 100644 --- a/example/tests/test_sideload_resources.py +++ b/example/tests/test_sideload_resources.py @@ -3,7 +3,7 @@ """ import json -from django.core.urlresolvers import reverse +from django.urls import reverse from django.utils import encoding from example.tests import TestBase From 658a07c70ee4e79fc7b1974b962c52c29bb40b81 Mon Sep 17 00:00:00 2001 From: Matt Layman Date: Wed, 24 Jan 2018 11:33:10 -0500 Subject: [PATCH 8/8] Update minimum required django-polymorphic. Older versions of django-polymorphic don't support Django 2.0 --- requirements-development.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements-development.txt b/requirements-development.txt index 4e6a178c..e84b7d1a 100644 --- a/requirements-development.txt +++ b/requirements-development.txt @@ -1,5 +1,5 @@ -e . -django-polymorphic +django-polymorphic>=2.0 Faker isort mock diff --git a/setup.py b/setup.py index 4dfe6bed..90dc4e6c 100755 --- a/setup.py +++ b/setup.py @@ -108,7 +108,7 @@ def get_package_data(package): 'factory-boy<2.9.0', 'pytest-django', 'pytest>=2.8,<3', - 'django-polymorphic', + 'django-polymorphic>=2.0', 'packaging', 'django-debug-toolbar' ] + mock,