Skip to content

Commit 7eb4106

Browse files
authored
Merge pull request #202 from patrick91/feature/up-django
Remove support to django 1.6 and 1.7
2 parents 06f8323 + 82055ac commit 7eb4106

File tree

7 files changed

+12
-71
lines changed

7 files changed

+12
-71
lines changed

.travis.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ env:
4949
matrix:
5050
fast_finish: true
5151
include:
52-
- python: '2.7'
53-
env: TEST_TYPE=build DJANGO_VERSION=1.6
54-
- python: '2.7'
55-
env: TEST_TYPE=build DJANGO_VERSION=1.7
5652
- python: '2.7'
5753
env: TEST_TYPE=build DJANGO_VERSION=1.8
5854
- python: '2.7'

graphene_django/compat.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,10 @@
1-
from django.db import models
2-
3-
41
class MissingType(object):
52
pass
63

74

85
try:
9-
DurationField = models.DurationField
10-
UUIDField = models.UUIDField
11-
except AttributeError:
12-
# Improved compatibility for Django 1.6
13-
DurationField = MissingType
14-
UUIDField = MissingType
15-
16-
try:
17-
from django.db.models.related import RelatedObject
18-
except:
19-
# Improved compatibility for Django 1.6
20-
RelatedObject = MissingType
21-
22-
23-
try:
24-
# Postgres fields are only available in Django 1.8+
6+
# Postgres fields are only available in Django with psycopg2 installed
7+
# and we cannot have psycopg2 on PyPy
258
from django.contrib.postgres.fields import ArrayField, HStoreField, RangeField
269
except ImportError:
2710
ArrayField, HStoreField, JSONField, RangeField = (MissingType, ) * 4

graphene_django/converter.py

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
from graphene.utils.str_converters import to_camel_case, to_const
1010
from graphql import assert_valid_name
1111

12-
from .compat import (ArrayField, HStoreField, JSONField, RangeField,
13-
RelatedObject, UUIDField, DurationField)
12+
from .compat import ArrayField, HStoreField, JSONField, RangeField
1413
from .fields import get_connection_field, DjangoListField
1514
from .utils import get_related_model, import_single_dispatch
1615

@@ -80,7 +79,7 @@ def convert_field_to_string(field, registry=None):
8079

8180

8281
@convert_django_field.register(models.AutoField)
83-
@convert_django_field.register(UUIDField)
82+
@convert_django_field.register(models.UUIDField)
8483
def convert_field_to_id(field, registry=None):
8584
return ID(description=field.help_text, required=not field.null)
8685

@@ -106,7 +105,7 @@ def convert_field_to_nullboolean(field, registry=None):
106105

107106
@convert_django_field.register(models.DecimalField)
108107
@convert_django_field.register(models.FloatField)
109-
@convert_django_field.register(DurationField)
108+
@convert_django_field.register(models.DurationField)
110109
def convert_field_to_float(field, registry=None):
111110
return Float(description=field.help_text, required=not field.null)
112111

@@ -157,26 +156,6 @@ def dynamic_type():
157156
return Dynamic(dynamic_type)
158157

159158

160-
# For Django 1.6
161-
@convert_django_field.register(RelatedObject)
162-
def convert_relatedfield_to_djangomodel(field, registry=None):
163-
model = field.model
164-
165-
def dynamic_type():
166-
_type = registry.get_type_for_model(model)
167-
if not _type:
168-
return
169-
170-
if isinstance(field.field, models.OneToOneField):
171-
return Field(_type)
172-
173-
if is_node(_type):
174-
return get_connection_field(_type)
175-
return DjangoListField(_type)
176-
177-
return Dynamic(dynamic_type)
178-
179-
180159
@convert_django_field.register(models.OneToOneField)
181160
@convert_django_field.register(models.ForeignKey)
182161
def convert_field_to_djangomodel(field, registry=None):

graphene_django/debug/tests/test_query.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import graphene
44
from graphene.relay import Node
55
from graphene_django import DjangoConnectionField, DjangoObjectType
6-
from graphene_django.utils import DJANGO_FILTER_INSTALLED
76

87
from ...tests.models import Reporter
98
from ..middleware import DjangoDebugMiddleware
@@ -167,8 +166,6 @@ def resolve_all_reporters(self, *args, **kwargs):
167166
assert result.data['__debug']['sql'][1]['rawSql'] == query
168167

169168

170-
@pytest.mark.skipif(not DJANGO_FILTER_INSTALLED,
171-
reason="requires django-filter")
172169
def test_should_query_connectionfilter():
173170
from ...filter import DjangoFilterConnectionField
174171

graphene_django/tests/test_converter.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
from graphene.types.datetime import DateTime, Time
99
from graphene.types.json import JSONString
1010

11-
from ..compat import (ArrayField, HStoreField, JSONField, MissingType,
12-
RangeField, UUIDField, DurationField)
11+
from ..compat import JSONField, ArrayField, HStoreField, RangeField, MissingType
1312
from ..converter import convert_django_field, convert_django_field_with_choices
1413
from ..registry import Registry
1514
from ..types import DjangoObjectType
@@ -84,14 +83,12 @@ def test_should_auto_convert_id():
8483
assert_conversion(models.AutoField, graphene.ID, primary_key=True)
8584

8685

87-
@pytest.mark.skipif(UUIDField == MissingType, reason="requires Django UUIDField")
8886
def test_should_auto_convert_id():
89-
assert_conversion(UUIDField, graphene.ID)
87+
assert_conversion(models.UUIDField, graphene.ID)
9088

9189

92-
@pytest.mark.skipif(DurationField == MissingType, reason="requires Django DurationField")
9390
def test_should_auto_convert_duration():
94-
assert_conversion(DurationField, graphene.Float)
91+
assert_conversion(models.DurationField, graphene.Float)
9592

9693

9794
def test_should_positive_integer_convert_int():

graphene_django/utils.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
from django.db import models
44
from django.db.models.manager import Manager
55

6-
from .compat import RelatedObject
7-
86

97
# from graphene.utils import LazyList
108

@@ -13,12 +11,8 @@ class LazyList(object):
1311
pass
1412

1513

16-
try:
17-
import django_filters # noqa
18-
DJANGO_FILTER_INSTALLED = True
19-
except (ImportError, AttributeError):
20-
# AtributeError raised if DjangoFilters installed with a incompatible Django Version
21-
DJANGO_FILTER_INSTALLED = False
14+
import django_filters # noqa
15+
DJANGO_FILTER_INSTALLED = True
2216

2317

2418
def get_reverse_fields(model, local_field_names):
@@ -30,12 +24,7 @@ def get_reverse_fields(model, local_field_names):
3024
# Django =>1.9 uses 'rel', django <1.9 uses 'related'
3125
related = getattr(attr, 'rel', None) or \
3226
getattr(attr, 'related', None)
33-
if isinstance(related, RelatedObject):
34-
# Hack for making it compatible with Django 1.6
35-
new_related = RelatedObject(related.parent_model, related.model, related.field)
36-
new_related.name = name
37-
yield (name, new_related)
38-
elif isinstance(related, models.ManyToOneRel):
27+
if isinstance(related, models.ManyToOneRel):
3928
yield (name, related)
4029
elif isinstance(related, models.ManyToManyRel) and not related.symmetrical:
4130
yield (name, related)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
install_requires=[
4545
'six>=1.10.0',
4646
'graphene>=1.4',
47-
'Django>=1.6.0',
47+
'Django>=1.8.0',
4848
'iso8601',
4949
'singledispatch>=3.4.0.3',
5050
],

0 commit comments

Comments
 (0)