Skip to content

ArrayField converter broke in Django 1.8.* #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fabiocerqueira opened this issue Nov 3, 2016 · 0 comments
Closed

ArrayField converter broke in Django 1.8.* #40

fabiocerqueira opened this issue Nov 3, 2016 · 0 comments

Comments

@fabiocerqueira
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant