diff --git a/.travis.yml b/.travis.yml index 6450bd2..b219f33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,10 +49,6 @@ env: matrix: fast_finish: true include: - - python: '2.7' - env: TEST_TYPE=build DJANGO_VERSION=1.6 - - python: '2.7' - env: TEST_TYPE=build DJANGO_VERSION=1.7 - python: '2.7' env: TEST_TYPE=build DJANGO_VERSION=1.8 - python: '2.7' diff --git a/graphene_django/compat.py b/graphene_django/compat.py index 49ea68f..0269e33 100644 --- a/graphene_django/compat.py +++ b/graphene_django/compat.py @@ -1,27 +1,10 @@ -from django.db import models - - class MissingType(object): pass try: - DurationField = models.DurationField - UUIDField = models.UUIDField -except AttributeError: - # Improved compatibility for Django 1.6 - DurationField = MissingType - UUIDField = MissingType - -try: - from django.db.models.related import RelatedObject -except: - # Improved compatibility for Django 1.6 - RelatedObject = MissingType - - -try: - # Postgres fields are only available in Django 1.8+ + # Postgres fields are only available in Django with psycopg2 installed + # and we cannot have psycopg2 on PyPy from django.contrib.postgres.fields import ArrayField, HStoreField, RangeField except ImportError: ArrayField, HStoreField, JSONField, RangeField = (MissingType, ) * 4 diff --git a/graphene_django/converter.py b/graphene_django/converter.py index 92812d1..b1a8837 100644 --- a/graphene_django/converter.py +++ b/graphene_django/converter.py @@ -9,8 +9,7 @@ from graphene.types.json import JSONString from graphene.utils.str_converters import to_camel_case, to_const from graphql import assert_valid_name -from .compat import (ArrayField, HStoreField, JSONField, RangeField, - RelatedObject, UUIDField, DurationField) +from .compat import ArrayField, HStoreField, JSONField, RangeField from .fields import get_connection_field, DjangoListField from .utils import get_related_model, import_single_dispatch @@ -80,7 +79,7 @@ def convert_field_to_string(field, registry=None): @convert_django_field.register(models.AutoField) -@convert_django_field.register(UUIDField) +@convert_django_field.register(models.UUIDField) def convert_field_to_id(field, registry=None): return ID(description=field.help_text, required=not field.null) @@ -106,7 +105,7 @@ def convert_field_to_nullboolean(field, registry=None): @convert_django_field.register(models.DecimalField) @convert_django_field.register(models.FloatField) -@convert_django_field.register(DurationField) +@convert_django_field.register(models.DurationField) def convert_field_to_float(field, registry=None): return Float(description=field.help_text, required=not field.null) @@ -157,26 +156,6 @@ def convert_field_to_list_or_connection(field, registry=None): return Dynamic(dynamic_type) -# For Django 1.6 -@convert_django_field.register(RelatedObject) -def convert_relatedfield_to_djangomodel(field, registry=None): - model = field.model - - def dynamic_type(): - _type = registry.get_type_for_model(model) - if not _type: - return - - if isinstance(field.field, models.OneToOneField): - return Field(_type) - - if is_node(_type): - return get_connection_field(_type) - return DjangoListField(_type) - - return Dynamic(dynamic_type) - - @convert_django_field.register(models.OneToOneField) @convert_django_field.register(models.ForeignKey) def convert_field_to_djangomodel(field, registry=None): diff --git a/graphene_django/debug/tests/test_query.py b/graphene_django/debug/tests/test_query.py index e0851e7..3cb2ff7 100644 --- a/graphene_django/debug/tests/test_query.py +++ b/graphene_django/debug/tests/test_query.py @@ -3,7 +3,6 @@ import pytest import graphene from graphene.relay import Node from graphene_django import DjangoConnectionField, DjangoObjectType -from graphene_django.utils import DJANGO_FILTER_INSTALLED from ...tests.models import Reporter from ..middleware import DjangoDebugMiddleware @@ -167,8 +166,6 @@ def test_should_query_connection(): assert result.data['__debug']['sql'][1]['rawSql'] == query -@pytest.mark.skipif(not DJANGO_FILTER_INSTALLED, - reason="requires django-filter") def test_should_query_connectionfilter(): from ...filter import DjangoFilterConnectionField diff --git a/graphene_django/tests/test_converter.py b/graphene_django/tests/test_converter.py index 997b03c..35caa15 100644 --- a/graphene_django/tests/test_converter.py +++ b/graphene_django/tests/test_converter.py @@ -8,8 +8,7 @@ from graphene.relay import ConnectionField, Node from graphene.types.datetime import DateTime, Time from graphene.types.json import JSONString -from ..compat import (ArrayField, HStoreField, JSONField, MissingType, - RangeField, UUIDField, DurationField) +from ..compat import JSONField, ArrayField, HStoreField, RangeField, MissingType from ..converter import convert_django_field, convert_django_field_with_choices from ..registry import Registry from ..types import DjangoObjectType @@ -84,14 +83,12 @@ def test_should_auto_convert_id(): assert_conversion(models.AutoField, graphene.ID, primary_key=True) -@pytest.mark.skipif(UUIDField == MissingType, reason="requires Django UUIDField") def test_should_auto_convert_id(): - assert_conversion(UUIDField, graphene.ID) + assert_conversion(models.UUIDField, graphene.ID) -@pytest.mark.skipif(DurationField == MissingType, reason="requires Django DurationField") def test_should_auto_convert_duration(): - assert_conversion(DurationField, graphene.Float) + assert_conversion(models.DurationField, graphene.Float) def test_should_positive_integer_convert_int(): diff --git a/graphene_django/utils.py b/graphene_django/utils.py index 3ea4d0d..468dc4c 100644 --- a/graphene_django/utils.py +++ b/graphene_django/utils.py @@ -3,8 +3,6 @@ import inspect from django.db import models from django.db.models.manager import Manager -from .compat import RelatedObject - # from graphene.utils import LazyList @@ -13,12 +11,8 @@ class LazyList(object): pass -try: - import django_filters # noqa - DJANGO_FILTER_INSTALLED = True -except (ImportError, AttributeError): - # AtributeError raised if DjangoFilters installed with a incompatible Django Version - DJANGO_FILTER_INSTALLED = False +import django_filters # noqa +DJANGO_FILTER_INSTALLED = True def get_reverse_fields(model, local_field_names): @@ -30,12 +24,7 @@ def get_reverse_fields(model, local_field_names): # Django =>1.9 uses 'rel', django <1.9 uses 'related' related = getattr(attr, 'rel', None) or \ getattr(attr, 'related', None) - if isinstance(related, RelatedObject): - # Hack for making it compatible with Django 1.6 - new_related = RelatedObject(related.parent_model, related.model, related.field) - new_related.name = name - yield (name, new_related) - elif isinstance(related, models.ManyToOneRel): + if isinstance(related, models.ManyToOneRel): yield (name, related) elif isinstance(related, models.ManyToManyRel) and not related.symmetrical: yield (name, related) diff --git a/setup.py b/setup.py index 2d2e578..9673d9b 100644 --- a/setup.py +++ b/setup.py @@ -44,7 +44,7 @@ setup( install_requires=[ 'six>=1.10.0', 'graphene>=1.4', - 'Django>=1.6.0', + 'Django>=1.8.0', 'iso8601', 'singledispatch>=3.4.0.3', ],