mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-04-13 05:34:20 +03:00
eat: add Django 2 compatibility
This commit is contained in:
parent
72ae5f512e
commit
9f4ddb8a74
4
.github/workflows/tests.yml
vendored
4
.github/workflows/tests.yml
vendored
|
@ -11,6 +11,10 @@ jobs:
|
|||
django: ["3.2", "4.1", "4.2"]
|
||||
python-version: ["3.8", "3.9", "3.10"]
|
||||
include:
|
||||
- django: "2.2"
|
||||
python-version: "3.10"
|
||||
- django: "2.2"
|
||||
python-version: "3.11"
|
||||
- django: "3.2"
|
||||
python-version: "3.7"
|
||||
- django: "4.1"
|
||||
|
|
|
@ -1,9 +1,3 @@
|
|||
# For backwards compatibility, we import JSONField to have it available for import via
|
||||
# this compat module (https://github.com/graphql-python/graphene-django/issues/1428).
|
||||
# Django's JSONField is available in Django 3.2+ (the minimum version we support)
|
||||
from django.db.models import JSONField
|
||||
|
||||
|
||||
class MissingType:
|
||||
def __init__(self, *args, **kwargs):
|
||||
pass
|
||||
|
@ -18,5 +12,12 @@ try:
|
|||
HStoreField,
|
||||
RangeField,
|
||||
)
|
||||
|
||||
try:
|
||||
from django.db.models import JSONField
|
||||
except ImportError:
|
||||
from django.contrib.postgres.fields import JSONField
|
||||
except ImportError:
|
||||
IntegerRangeField, ArrayField, HStoreField, RangeField = (MissingType,) * 4
|
||||
IntegerRangeField, ArrayField, HStoreField, RangeField, JSONField = (
|
||||
MissingType,
|
||||
) * 5
|
||||
|
|
|
@ -37,7 +37,7 @@ except ImportError:
|
|||
from graphql import assert_valid_name as assert_name
|
||||
from graphql.pyutils import register_description
|
||||
|
||||
from .compat import ArrayField, HStoreField, RangeField
|
||||
from .compat import ArrayField, HStoreField, RangeField, JSONField
|
||||
from .fields import DjangoListField, DjangoConnectionField
|
||||
from .settings import graphene_settings
|
||||
from .utils.str_converters import to_const
|
||||
|
@ -471,7 +471,7 @@ def convert_postgres_array_to_list(field, registry=None):
|
|||
|
||||
|
||||
@convert_django_field.register(HStoreField)
|
||||
@convert_django_field.register(models.JSONField)
|
||||
@convert_django_field.register(JSONField)
|
||||
def convert_json_field_to_string(field, registry=None):
|
||||
return JSONString(
|
||||
description=get_django_field_description(field), required=not field.null
|
||||
|
|
|
@ -11,7 +11,7 @@ from pytest import raises
|
|||
import graphene
|
||||
from graphene.relay import Node
|
||||
|
||||
from ..compat import IntegerRangeField, MissingType
|
||||
from ..compat import IntegerRangeField, MissingType, JSONField
|
||||
from ..fields import DjangoConnectionField
|
||||
from ..types import DjangoObjectType
|
||||
from ..utils import DJANGO_FILTER_INSTALLED
|
||||
|
@ -133,7 +133,7 @@ def test_should_query_postgres_fields():
|
|||
|
||||
class Event(models.Model):
|
||||
ages = IntegerRangeField(help_text="The age ranges")
|
||||
data = models.JSONField(help_text="Data")
|
||||
data = JSONField(help_text="Data")
|
||||
store = HStoreField()
|
||||
tags = ArrayField(models.CharField(max_length=50))
|
||||
|
||||
|
|
4
setup.py
4
setup.py
|
@ -20,7 +20,7 @@ tests_require = [
|
|||
"coveralls",
|
||||
"mock",
|
||||
"pytz",
|
||||
"django-filter>=22.1",
|
||||
"django-filter>=21.1",
|
||||
"pytest-django>=4.5.2",
|
||||
] + rest_framework_require
|
||||
|
||||
|
@ -65,7 +65,7 @@ setup(
|
|||
"graphene @ git+https://github.com/graphql-python/graphene.git@ee1ff975d71f6590eb6933d76d12054c9839774a#egg=graphene",
|
||||
"graphql-core>=3.1.0,<4",
|
||||
"graphql-relay @ git+https://github.com/loft-orbital/graphql-relay-py.git@loft-v3.2.0-1#egg=graphql-relay",
|
||||
"Django>=3.2",
|
||||
"Django>=2.2.13",
|
||||
"promise>=2.1",
|
||||
"text-unidecode",
|
||||
],
|
||||
|
|
3
tox.ini
3
tox.ini
|
@ -1,5 +1,6 @@
|
|||
[tox]
|
||||
envlist =
|
||||
py{37,38,39,310}-django22,
|
||||
py{37,38,39,310}-django32,
|
||||
py{38,39,310}-django{41,42,main},
|
||||
py311-django{41,42,main}
|
||||
|
@ -15,6 +16,7 @@ python =
|
|||
|
||||
[gh-actions:env]
|
||||
DJANGO =
|
||||
2.2: django22
|
||||
3.2: django32
|
||||
4.1: django41
|
||||
4.2: django42
|
||||
|
@ -29,6 +31,7 @@ setenv =
|
|||
deps =
|
||||
-e.[test]
|
||||
psycopg2-binary
|
||||
django22: Django==2.2.13
|
||||
django32: Django>=3.2,<4.0
|
||||
django41: Django>=4.1,<4.2
|
||||
django42: Django>=4.2,<4.3
|
||||
|
|
Loading…
Reference in New Issue
Block a user