Repository: graphql-python/graphene-django

Issue:
Bug with Django ChoiceField
Hi, hi 
I got one bug using `models.CharField` with choices. 
Graphene is creating two differents objects as `Enum`. 
Raising one error in `graphene.types.typemap`

```
File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 64, in reducer
    return self.graphene_reducer(map, type)
  File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 82, in graphene_reducer
    return self.construct_objecttype(map, type)
  File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 153, in construct_objecttype
    map[type._meta.name]._fields = self.construct_fields_for_type(map, type)
  File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 214, in construct_fields_for_type
    map = self.reducer(map, field.type)
  File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 64, in reducer
    return self.graphene_reducer(map, type)
  File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 82, in graphene_reducer
    return self.construct_objecttype(map, type)
  File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 153, in construct_objecttype
    map[type._meta.name]._fields = self.construct_fields_for_type(map, type)
  File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 214, in construct_fields_for_type
    map = self.reducer(map, field.type)
  File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 64, in reducer
    return self.graphene_reducer(map, type)
  File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 69, in graphene_reducer
    return self.reducer(map, type.of_type)
  File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 64, in reducer
    return self.graphene_reducer(map, type)
  File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 79, in graphene_reducer
    assert _type.graphene_type == type
AssertionError
********************************************************************************
_type.graphene_type  UserMobile1Os 139869850885568
type UserMobile1Os 139869850674512
********************************************************************************
```

My model

```
MOBILE_PLATFORMS_CHOICES = (
    ('android', 'Android'),
    ('ios', 'iOS'),
)


class User(AbstractUser):
    full_name = models.CharField(max_length=64, blank=True)
    mobile_1_os = models.CharField(max_length=10, default='android',
                                   choices=MOBILE_PLATFORMS_CHOICES,
                                   db_index=True)

```

My query

```
class Query(graphene.AbstractType):
    users = DjangoConnectionField(
        UserNode
    )
```

My `UserNode` 

```
class UserNode(DjangoObjectType):
    class Meta(object):
        interfaces = (relay.Node,)
        model = User
```

And I have one file for `Schemas`

```
class AllQuery(Query, ObjectType):

   viewer = graphene.Field(lambda: AllQuery)

    @classmethod
    def resolve_viewer(cls, *args, **kwargs):
        return AllQuery()

schema_graphene = graphene.Schema(query=AllQuery)
```


Discussion:
This big number (139869850885568 and 139869850674512) is `id(_type.graphene_type) and id(type)`
Having the exact same issue with 1.10.5x1.1.3x1.2.1 at `graphene/types/typemap.py in graphene_reducer, line 73`: the expression `_type.graphene_type == type` evaluates to `False`.

Using a debugger I could see how `id(_type.graphene_type)` is different that `id(type)` for the enums created out of  "choices". `id(..)` on all other types compare.
Same problem on graphene 1.2.0

Resolving patch:
diff --git a/graphene_django/converter.py b/graphene_django/converter.py
--- a/graphene_django/converter.py
+++ b/graphene_django/converter.py
@@ -41,6 +41,10 @@ def get_choices(choices):
 
 
 def convert_django_field_with_choices(field, registry=None):
+    if registry is not None:
+        converted = registry.get_converted_field(field)
+        if converted:
+            return converted
     choices = getattr(field, 'choices', None)
     if choices:
         meta = field.model._meta
@@ -56,8 +60,12 @@ def description(self):
                 return named_choices_descriptions[self.name]
 
         enum = Enum(name, list(named_choices), type=EnumWithDescriptionsType)
-        return enum(description=field.help_text, required=not field.null)
-    return convert_django_field(field, registry)
+        converted = enum(description=field.help_text, required=not field.null)
+    else:
+        converted = convert_django_field(field, registry)
+    if registry is not None:
+        registry.register_converted_field(field, converted)
+    return converted
 
 
 @singledispatch
diff --git a/graphene_django/registry.py b/graphene_django/registry.py
--- a/graphene_django/registry.py
+++ b/graphene_django/registry.py
@@ -2,7 +2,7 @@ class Registry(object):
 
     def __init__(self):
         self._registry = {}
-        self._registry_models = {}
+        self._field_registry = {}
 
     def register(self, cls):
         from .types import DjangoObjectType
@@ -19,6 +19,12 @@ def register(self, cls):
     def get_type_for_model(self, model):
         return self._registry.get(model)
 
+    def register_converted_field(self, field, converted):
+        self._field_registry[field] = converted
+
+    def get_converted_field(self, field):
+        return self._field_registry.get(field)
+
 
 registry = None
 


Test patch:
diff --git a/graphene_django/tests/test_query.py b/graphene_django/tests/test_query.py
--- a/graphene_django/tests/test_query.py
+++ b/graphene_django/tests/test_query.py
@@ -747,3 +747,35 @@ class Query(graphene.ObjectType):
     result = schema.execute(query)
     assert not result.errors
     assert result.data == expected
+
+
+def test_should_handle_inherited_choices():
+    class BaseModel(models.Model):
+        choice_field = models.IntegerField(choices=((0, 'zero'), (1, 'one')))
+
+    class ChildModel(BaseModel):
+        class Meta:
+            proxy = True
+
+    class BaseType(DjangoObjectType):
+        class Meta:
+            model = BaseModel
+
+    class ChildType(DjangoObjectType):
+        class Meta:
+            model = ChildModel
+
+    class Query(graphene.ObjectType):
+        base = graphene.Field(BaseType)
+        child = graphene.Field(ChildType)
+
+    schema = graphene.Schema(query=Query)
+    query = '''
+        query {
+          child {
+            choiceField
+          }
+        }
+    '''
+    result = schema.execute(query)
+    assert not result.errors