Skip to content

ArrayField converter broke in Django 1.8.* #40

Closed
@fabiocerqueira

Description

@fabiocerqueira

Guys,

JSONField was added just in Django 1.9[1] and in graphene code try import that as version 1.8.*
This could cause problem to convert_postgres_array_to_list, because if I'm using django 1.8 graphene_django will try import JSONField causing a ImportError and broke all the others imports.

A possible solution below:

try:
    # Postgres fields are only available in Django 1.8+
    from django.contrib.postgres.fields import ArrayField, HStoreField, RangeField
except ImportError:
    ArrayField, HStoreField, RangeField = (MissingType, ) * 3


try:
    # Postgres fields are only available in Django 1.9+
    from django.contrib.postgres.fields import JSONField
except ImportError:
    JSONField = MissingType

[1] - https://docs.djangoproject.com/en/1.9/releases/1.9/
[2] - https://github.com/graphql-python/graphene-django/blob/master/graphene_django/compat.py#L23

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions