Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b0257c0

Browse files
Drop support for Django 1.8 - 1.10 (#387)
* Drop support for loading of testing. * Add specificity to DRF support. * Drop old version support for utils.py * Make isort happy. * Update relations.py and views.py to remove old version specific checks. * More isort joy. * Got a bit overzealous deleting some stuff. * Remove a deprecation notice.
1 parent e85cea9 commit b0257c0

File tree

11 files changed

+49
-142
lines changed

11 files changed

+49
-142
lines changed

‎.travis.yml‎

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,13 @@
22
language: python
33
sudo: false
44
cache: pip
5-
matrix:
6-
exclude:
7-
- python: "3.3"
8-
env: DJANGO=">=1.9,<1.10" DRF=">=3.3,<3.4"
9-
- python: "3.3"
10-
env: DJANGO=">=1.9,<1.10" DRF=">=3.4,<3.5"
11-
- python: "3.3"
12-
env: DJANGO=">=1.10,<1.11" DRF=">=3.4,<3.5"
13-
- python: "3.3"
14-
env: DJANGO=">=1.11,<1.12" DRF=">=3.4,<3.5"
15-
- python: "3.3"
16-
env: DJANGO=">=1.11,<1.12" DRF=">=3.5,<3.6"
17-
- python: "3.3"
18-
env: DJANGO=">=1.11,<1.12" DRF=">=3.6,<3.7"
195
python:
206
- "2.7"
21-
- "3.3"
227
- "3.4"
238
- "3.5"
249
- "3.6"
2510
env:
26-
- DJANGO=">=1.8,<1.9" DRF=">=3.1,<3.2"
27-
- DJANGO=">=1.8,<1.9" DRF=">=3.2,<3.3"
28-
- DJANGO=">=1.8,<1.9" DRF=">=3.3,<3.4"
29-
- DJANGO=">=1.8,<1.9" DRF=">=3.4,<3.5"
30-
31-
- DJANGO=">=1.9,<1.10" DRF=">=3.3,<3.4"
32-
- DJANGO=">=1.9,<1.10" DRF=">=3.4,<3.5"
33-
34-
- DJANGO=">=1.10,<1.11" DRF=">=3.4,<3.5"
35-
36-
- DJANGO=">=1.11,<1.12" DRF=">=3.4,<3.5"
37-
- DJANGO=">=1.11,<1.12" DRF=">=3.5,<3.6"
38-
- DJANGO=">=1.11,<1.12" DRF=">=3.6,<3.7"
11+
- DJANGO=">=1.11,<1.12" DRF=">=3.6.3,<3.7"
3912
before_install:
4013
# Force an upgrade of py & pytest to avoid VersionConflict
4114
- pip install --upgrade py

‎AUTHORS‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Greg Aker <greg@gregaker.net>
44
Jamie Bliss <astronouth7303@gmail.com>
55
Jerel Unruh <mail@unruhdesigns.com>
66
Léo S. <leo@naeka.fr>
7-
Matt Layman <http://www.mattlayman.com>
7+
Matt Layman <https://www.mattlayman.com>
88
Ola Tarkowska <ola@red-aries.com>
99
Oliver Sauder <os@esite.ch>
1010
Raphael Cohen <raphael.cohen.utt@gmail.com>

‎CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
v2.4.0
2+
3+
* Drop support for Django 1.8 - 1.10 (EOL)
4+
* Drop support for Django REST Framework < 3.6.3
5+
(3.6.3 is the first to support Django 1.11)
6+
* Drop support for Python 3.3 (EOL)
7+
18
v2.3.0 - Released November 28, 2017
29

310
* Added support for polymorphic models

‎README.rst‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,10 @@ JSON API and Django Rest Framework
99
:alt: Read the docs
1010
:target: http://django-rest-framework-json-api.readthedocs.org/
1111

12-
.. image:: https://codeclimate.com/github/django-json-api/django-rest-framework-json-api/badges/gpa.svg
13-
:target: https://codeclimate.com/github/django-json-api/django-rest-framework-json-api
14-
:alt: Code Climate
15-
1612
.. image:: https://badges.gitter.im/Join%20Chat.svg
1713
:alt: Join the chat at https://gitter.im/django-json-api/django-rest-framework-json-api
1814
:target: https://gitter.im/django-json-api/django-rest-framework-json-api
1915

20-
2116
--------
2217
Overview
2318
--------
@@ -72,9 +67,9 @@ like the following::
7267
Requirements
7368
------------
7469

75-
1. Python (2.7, 3.3, 3.4, 3.5, 3.6)
76-
2. Django (1.8, 1.9, 1.10, 1.11)
77-
3. Django REST Framework (3.1, 3.2, 3.3, 3.4, 3.5, 3.6)
70+
1. Python (2.7, 3.4, 3.5, 3.6)
71+
2. Django (1.11)
72+
3. Django REST Framework (3.6)
7873

7974
------------
8075
Installation
@@ -94,7 +89,8 @@ From Source
9489
::
9590

9691
$ git clone https://github.com/django-json-api/django-rest-framework-json-api.git
97-
$ cd django-rest-framework-json-api && pip install -e .
92+
$ cd django-rest-framework-json-api
93+
$ pip install -e .
9894

9995

10096
Running the example app
@@ -103,7 +99,8 @@ Running the example app
10399
::
104100

105101
$ git clone https://github.com/django-json-api/django-rest-framework-json-api.git
106-
$ cd django-rest-framework-json-api && pip install -e .
102+
$ cd django-rest-framework-json-api
103+
$ pip install -e .
107104
$ django-admin.py runserver --settings=example.settings
108105

109106
Browse to http://localhost:8000
@@ -112,7 +109,7 @@ Browse to http://localhost:8000
112109
Running Tests
113110
^^^^^^^^^^^^^
114111

115-
It is recommended to create a virtualenv for testing. Assuming it is already
112+
It is recommended to create a virtualenv for testing. Assuming it is already
116113
installed and activated:
117114

118115
::

‎docs/getting-started.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ like the following:
5151

5252
## Requirements
5353

54-
1. Python (2.7, 3.3, 3.4, 3.5, 3.6)
55-
2. Django (1.8, 1.9, 1.10, 1.11)
56-
3. Django REST Framework (3.1, 3.2, 3.3, 3.4, 3.5, 3.6)
54+
1. Python (2.7, 3.4, 3.5, 3.6)
55+
2. Django (1.11)
56+
3. Django REST Framework (3.6)
5757

5858
## Installation
5959

‎rest_framework_json_api/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22

33
__title__ = 'djangorestframework-jsonapi'
4-
__version__ = '2.3.1'
4+
__version__ = '2.4.0'
55
__author__ = ''
66
__license__ = 'MIT'
77
__copyright__ = ''

‎rest_framework_json_api/relations.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import inflection
66
import six
77
from django.core.exceptions import ImproperlyConfigured
8-
from django.core.urlresolvers import NoReverseMatch
8+
from django.urls import NoReverseMatch
99
from django.utils.translation import ugettext_lazy as _
1010
from rest_framework.fields import MISSING_ERROR_MESSAGE
1111
from rest_framework.relations import MANY_RELATION_KWARGS, PrimaryKeyRelatedField
@@ -291,8 +291,6 @@ def __new__(cls, *args, **kwargs):
291291
return super(ResourceRelatedField, cls).__new__(cls, *args, **kwargs)
292292

293293
def __init__(self, child_relation=None, *args, **kwargs):
294-
# DRF 3.1 doesn't expect the `many` kwarg
295-
kwargs.pop('many', None)
296294
model = kwargs.pop('model', None)
297295
if child_relation is not None:
298296
self.child_relation = child_relation

‎rest_framework_json_api/utils.py‎

Lines changed: 12 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,34 @@
1-
"""
2-
Utils.
3-
"""
41
import copy
52
import inspect
63
import operator
74
import warnings
85
from collections import OrderedDict
96

10-
import django
117
import inflection
128
from django.conf import settings
139
from django.db.models import Manager
10+
from django.db.models.fields.related_descriptors import (
11+
ManyToManyDescriptor,
12+
ReverseManyToOneDescriptor
13+
)
1414
from django.utils import encoding, six
1515
from django.utils.module_loading import import_string as import_class_from_dotted_path
1616
from django.utils.translation import ugettext_lazy as _
1717
from rest_framework import exceptions
1818
from rest_framework.exceptions import APIException
19-
20-
try:
21-
from rest_framework.serializers import ManyRelatedField
22-
except ImportError:
23-
ManyRelatedField = object()
19+
from rest_framework.serializers import ManyRelatedField # noqa: F401
2420

2521
try:
2622
from rest_framework_nested.relations import HyperlinkedRouterField
2723
except ImportError:
2824
HyperlinkedRouterField = object()
2925

30-
if django.VERSION >= (1, 9):
31-
from django.db.models.fields.related_descriptors import (
32-
ManyToManyDescriptor, ReverseManyToOneDescriptor # noqa: F401
33-
)
34-
ReverseManyRelatedObjectsDescriptor = object()
35-
else:
36-
from django.db.models.fields.related import ( # noqa: F401
37-
ManyRelatedObjectsDescriptor as ManyToManyDescriptor
38-
)
39-
from django.db.models.fields.related import (
40-
ForeignRelatedObjectsDescriptor as ReverseManyToOneDescriptor
41-
)
42-
from django.db.models.fields.related import ReverseManyRelatedObjectsDescriptor # noqa: F401
43-
4426
# Generic relation descriptor from django.contrib.contenttypes.
4527
if 'django.contrib.contenttypes' not in settings.INSTALLED_APPS: # pragma: no cover
4628
# Target application does not use contenttypes. Importing would cause errors.
4729
ReverseGenericManyToOneDescriptor = object()
48-
elif django.VERSION >= (1, 9):
49-
from django.contrib.contenttypes.fields import ReverseGenericManyToOneDescriptor # noqa: F401
5030
else:
51-
from django.contrib.contenttypes.fields import ( # noqa: F401
52-
ReverseGenericRelatedObjectsDescriptor as ReverseGenericManyToOneDescriptor # noqa: F401
53-
)
31+
from django.contrib.contenttypes.fields import ReverseGenericManyToOneDescriptor
5432

5533

5634
def get_resource_name(context, expand_polymorphic_types=False):
@@ -236,30 +214,14 @@ def get_related_resource_type(relation):
236214

237215
parent_model_relation_type = type(parent_model_relation)
238216
if parent_model_relation_type is ReverseManyToOneDescriptor:
239-
if django.VERSION >= (1, 9):
240-
relation_model = parent_model_relation.rel.related_model
241-
elif django.VERSION >= (1, 8):
242-
relation_model = parent_model_relation.related.related_model
243-
else:
244-
relation_model = parent_model_relation.related.model
217+
relation_model = parent_model_relation.rel.related_model
245218
elif parent_model_relation_type is ManyToManyDescriptor:
246-
if django.VERSION >= (1, 9):
247-
relation_model = parent_model_relation.field.remote_field.model
248-
# In case we are in a reverse relation
249-
if relation_model == parent_model:
250-
relation_model = parent_model_relation.field.model
251-
elif django.VERSION >= (1, 8):
252-
relation_model = parent_model_relation.related.model
253-
# In case we are in a reverse relation
254-
if relation_model == parent_model:
255-
relation_model = parent_model_relation.related.related_model
256-
elif parent_model_relation_type is ReverseManyRelatedObjectsDescriptor:
257-
relation_model = parent_model_relation.field.related.model
219+
relation_model = parent_model_relation.field.remote_field.model
220+
# In case we are in a reverse relation
221+
if relation_model == parent_model:
222+
relation_model = parent_model_relation.field.model
258223
elif parent_model_relation_type is ReverseGenericManyToOneDescriptor:
259-
if django.VERSION >= (1, 9):
260-
relation_model = parent_model_relation.rel.model
261-
else:
262-
relation_model = parent_model_relation.field.related_model
224+
relation_model = parent_model_relation.rel.model
263225
elif hasattr(parent_model_relation, 'field'):
264226
try:
265227
relation_model = parent_model_relation.field.remote_field.model

‎rest_framework_json_api/views.py‎

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
import django
21
from django.core.exceptions import ImproperlyConfigured
32
from django.db.models import Model
3+
from django.db.models.fields.related_descriptors import (
4+
ForwardManyToOneDescriptor,
5+
ManyToManyDescriptor,
6+
ReverseManyToOneDescriptor,
7+
ReverseOneToOneDescriptor
8+
)
49
from django.db.models.manager import Manager
510
from django.db.models.query import QuerySet
11+
from django.urls import NoReverseMatch
612
from rest_framework import generics, viewsets
713
from rest_framework.exceptions import MethodNotAllowed, NotFound
814
from rest_framework.response import Response
@@ -18,30 +24,10 @@
1824
get_resource_type_from_instance
1925
)
2026

21-
if django.VERSION >= (1, 10):
22-
from django.urls import NoReverseMatch
23-
else:
24-
from django.core.urlresolvers import NoReverseMatch
25-
26-
if django.VERSION < (1, 9):
27-
from django.db.models.fields.related import (
28-
ForeignRelatedObjectsDescriptor as ReverseManyToOneDescriptor,
29-
ManyRelatedObjectsDescriptor as ManyToManyDescriptor,
30-
ReverseSingleRelatedObjectDescriptor as ForwardManyToOneDescriptor,
31-
SingleRelatedObjectDescriptor as ReverseOneToOneDescriptor,
32-
)
33-
else:
34-
from django.db.models.fields.related_descriptors import (
35-
ForwardManyToOneDescriptor,
36-
ManyToManyDescriptor,
37-
ReverseManyToOneDescriptor,
38-
ReverseOneToOneDescriptor,
39-
)
40-
4127

4228
class PrefetchForIncludesHelperMixin(object):
4329
def get_queryset(self):
44-
"""This viewset provides a helper attribute to prefetch related models
30+
"""This viewset provides a helper attribute to prefetch related models
4531
based on the include specified in the URL.
4632
4733
__all__ can be used to specify a prefetch which should be done regardless of the include
@@ -99,10 +85,7 @@ def get_queryset(self, *args, **kwargs):
9985
if level == levels[-1]:
10086
included_model = field
10187
else:
102-
if django.VERSION < (1, 9):
103-
model_field = field.related
104-
else:
105-
model_field = field.field
88+
model_field = field.field
10689

10790
if is_forward_relation:
10891
level_model = model_field.related_model
@@ -197,9 +180,8 @@ def patch(self, request, *args, **kwargs):
197180
related_instance_or_manager.all().delete()
198181
# have to set bulk to False since data isn't saved yet
199182
class_name = related_instance_or_manager.__class__.__name__
200-
if django.VERSION >= (1, 9) and class_name != 'ManyRelatedManager':
201-
related_instance_or_manager.add(*serializer.validated_data,
202-
bulk=False)
183+
if class_name != 'ManyRelatedManager':
184+
related_instance_or_manager.add(*serializer.validated_data, bulk=False)
203185
else:
204186
related_instance_or_manager.add(*serializer.validated_data)
205187
else:

‎setup.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ def get_package_data(package):
8989
'Programming Language :: Python :: 2',
9090
'Programming Language :: Python :: 2.7',
9191
'Programming Language :: Python :: 3',
92-
'Programming Language :: Python :: 3.3',
9392
'Programming Language :: Python :: 3.4',
9493
'Programming Language :: Python :: 3.5',
9594
'Programming Language :: Python :: 3.6',
@@ -99,8 +98,8 @@ def get_package_data(package):
9998
],
10099
install_requires=[
101100
'inflection>=0.3.0',
102-
'djangorestframework>=3.1.0',
103-
'django',
101+
'djangorestframework>=3.6.3',
102+
'django>=1.11',
104103
'six',
105104
],
106105
setup_requires=pytest_runner + sphinx + wheel,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /