Repository: graphql-python/graphene-django

Issue:
Several 'RemovedInDjango20Warning's with Django 1.11 (field.rel, ForeignObjectRel.to)
Hi!

When running our test suite with Python warnings enabled (eg `PYTHONWARNINGS=once pytest`), we get the following deprecation warnings:

```
  .../site-packages/graphene_django/utils.py:61: RemovedInDjango20Warning: Usage of field.rel has been deprecated. Use field.remote_field instead.
    if hasattr(field, 'rel'):
  .../site-packages/graphene_django/utils.py:63: RemovedInDjango20Warning: Usage of ForeignObjectRel.to attribute has been deprecated. Use the model attribute instead.
    return field.rel.to
```

These line numbers correspond to:
https://github.com/graphql-python/graphene-django/blob/v1.3/graphene_django/utils.py#L61
https://github.com/graphql-python/graphene-django/blob/v1.3/graphene_django/utils.py#L63

The deprecation docs for this are here:
https://docs.djangoproject.com/en/1.11/releases/1.9/#field-rel-changes

I'm presuming the solution would be to either:
1) Drop support for Django 1.6/1.7 entirely
2) Invert the conditional, such that it does `hasattr(field, 'related_model')` and if not found then falls back to `field.rel.to`.

Given Django <1.8 is EOL and has security vulnerabilities, I'd lean towards solution (1).

This was using:
* graphene-django 1.3
* graphene 1.4.1
* Django 1.11.4
* Python 2.7.13



Discussion:
Given Django 1.6/1.7 aren't tested in the Travis run, I presume solution (1) from above is acceptable.

I'm happy to open a PR - should I target master or the 2.0 branch?
Since this effects deployments that are out there now, I would think to have this pushed to master since it has very little to do with new features. Users of django previous and up to 1.8 aren't going to be receiving support from the django team especially since 2.0 will only support 3.x python and 1.11 is the last version of django to support 2.x python.

Resolving patch:
diff --git a/graphene_django/converter.py b/graphene_django/converter.py
--- a/graphene_django/converter.py
+++ b/graphene_django/converter.py
@@ -10,7 +10,7 @@
 
 from .compat import ArrayField, HStoreField, JSONField, RangeField
 from .fields import DjangoListField, DjangoConnectionField
-from .utils import get_related_model, import_single_dispatch
+from .utils import import_single_dispatch
 
 singledispatch = import_single_dispatch()
 
@@ -125,7 +125,7 @@ def convert_time_to_string(field, registry=None):
 
 @convert_django_field.register(models.OneToOneRel)
 def convert_onetoone_field_to_djangomodel(field, registry=None):
-    model = get_related_model(field)
+    model = field.related_model
 
     def dynamic_type():
         _type = registry.get_type_for_model(model)
@@ -144,7 +144,7 @@ def dynamic_type():
 @convert_django_field.register(models.ManyToManyRel)
 @convert_django_field.register(models.ManyToOneRel)
 def convert_field_to_list_or_connection(field, registry=None):
-    model = get_related_model(field)
+    model = field.related_model
 
     def dynamic_type():
         _type = registry.get_type_for_model(model)
@@ -170,7 +170,7 @@ def dynamic_type():
 @convert_django_field.register(models.OneToOneField)
 @convert_django_field.register(models.ForeignKey)
 def convert_field_to_djangomodel(field, registry=None):
-    model = get_related_model(field)
+    model = field.related_model
 
     def dynamic_type():
         _type = registry.get_type_for_model(model)
diff --git a/graphene_django/utils.py b/graphene_django/utils.py
--- a/graphene_django/utils.py
+++ b/graphene_django/utils.py
@@ -56,13 +56,6 @@ def get_model_fields(model):
     return all_fields
 
 
-def get_related_model(field):
-    if hasattr(field, 'rel'):
-        # Django 1.6, 1.7
-        return field.rel.to
-    return field.related_model
-
-
 def is_valid_django_model(model):
     return inspect.isclass(model) and issubclass(model, models.Model)
 


Test patch: