From a1dd2b629320ad70de618c82dab8a0050b38f56d Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Sat, 2 Apr 2016 16:24:32 -0700 Subject: [PATCH] Added FileField and ImageField conversion. Fixed #137 --- graphene/contrib/django/converter.py | 1 + graphene/contrib/django/tests/test_converter.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/graphene/contrib/django/converter.py b/graphene/contrib/django/converter.py index 89f90aa4..85cf9049 100644 --- a/graphene/contrib/django/converter.py +++ b/graphene/contrib/django/converter.py @@ -31,6 +31,7 @@ def convert_django_field(field): @convert_django_field.register(models.SlugField) @convert_django_field.register(models.URLField) @convert_django_field.register(models.GenericIPAddressField) +@convert_django_field.register(models.FileField) @convert_django_field.register(UUIDField) def convert_field_to_string(field): return String(description=field.help_text) diff --git a/graphene/contrib/django/tests/test_converter.py b/graphene/contrib/django/tests/test_converter.py index 1582b1ba..938e5556 100644 --- a/graphene/contrib/django/tests/test_converter.py +++ b/graphene/contrib/django/tests/test_converter.py @@ -53,6 +53,14 @@ def test_should_ipaddress_convert_string(): assert_conversion(models.GenericIPAddressField, graphene.String) +def test_should_file_convert_string(): + assert_conversion(models.FileField, graphene.String) + + +def test_should_image_convert_string(): + assert_conversion(models.ImageField, graphene.String) + + def test_should_auto_convert_id(): assert_conversion(models.AutoField, graphene.ID, primary_key=True)