Repository: graphql-python/graphene-django

Issue:
AttributeError: 'ForeignKey' object has no attribute 'rel'
As I was following the docs for [Graphene and Django Tutorial using Relay](http://docs.graphene-python.org/projects/django/en/latest/tutorial-relay/) I ran into this error (relevant part):
```
Traceback (most recent call last):
  File "/home/eyal0803/Projects/cookbook/venv/lib/python3.6/site-packages/graphene_django/settings.py", line 74, in import_from_string
    module = importlib.import_module(module_path)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/eyal0803/Projects/cookbook/cookbook/schema.py", line 10, in <module>
    schema = graphene.Schema(query=Query)
  File "/home/eyal0803/Projects/cookbook/venv/lib/python3.6/site-packages/graphene/types/schema.py", line 44, in __init__
    self.build_typemap()
  File "/home/eyal0803/Projects/cookbook/venv/lib/python3.6/site-packages/graphene/types/schema.py", line 105, in build_typemap
    self._type_map = TypeMap(initial_types, auto_camelcase=self.auto_camelcase, schema=self)
  File "/home/eyal0803/Projects/cookbook/venv/lib/python3.6/site-packages/graphene/types/typemap.py", line 66, in __init__
    super(TypeMap, self).__init__(types)
  File "/home/eyal0803/Projects/cookbook/venv/lib/python3.6/site-packages/graphql/type/typemap.py", line 16, in __init__
    self.update(reduce(self.reducer, types, OrderedDict()))
  File "/home/eyal0803/Projects/cookbook/venv/lib/python3.6/site-packages/graphene/types/typemap.py", line 74, in reducer
    return self.graphene_reducer(map, type)
  File "/home/eyal0803/Projects/cookbook/venv/lib/python3.6/site-packages/graphene/types/typemap.py", line 104, in graphene_reducer
    return GraphQLTypeMap.reducer(map, internal_type)
  File "/home/eyal0803/Projects/cookbook/venv/lib/python3.6/site-packages/graphql/type/typemap.py", line 79, in reducer
    field_map = type.fields
  File "/home/eyal0803/Projects/cookbook/venv/lib/python3.6/site-packages/graphql/pyutils/cached_property.py", line 16, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/eyal0803/Projects/cookbook/venv/lib/python3.6/site-packages/graphql/type/definition.py", line 180, in fields
    return define_field_map(self, self._fields)
  File "/home/eyal0803/Projects/cookbook/venv/lib/python3.6/site-packages/graphql/type/definition.py", line 189, in define_field_map
    field_map = field_map()
  File "/home/eyal0803/Projects/cookbook/venv/lib/python3.6/site-packages/graphene/types/typemap.py", line 257, in construct_fields_for_type
    for arg_name, arg in field.args.items():
  File "/home/eyal0803/Projects/cookbook/venv/lib/python3.6/site-packages/graphene_django/filter/fields.py", line 23, in args
    return to_arguments(self._base_args or OrderedDict(), self.filtering_args)
  File "/home/eyal0803/Projects/cookbook/venv/lib/python3.6/site-packages/graphene_django/filter/fields.py", line 44, in filtering_args
    return get_filtering_args_from_filterset(self.filterset_class, self.node_type)
  File "/home/eyal0803/Projects/cookbook/venv/lib/python3.6/site-packages/graphene_django/filter/fields.py", line 38, in filterset_class
    self._filterset_class = get_filterset_class(self._provided_filterset_class, **meta)
  File "/home/eyal0803/Projects/cookbook/venv/lib/python3.6/site-packages/graphene_django/filter/utils.py", line 28, in get_filterset_class
    return custom_filterset_factory(**meta)
  File "/home/eyal0803/Projects/cookbook/venv/lib/python3.6/site-packages/graphene_django/filter/filterset.py", line 102, in custom_filterset_factory
    'Meta': meta_class
  File "/home/eyal0803/Projects/cookbook/venv/lib/python3.6/site-packages/django_filters/filterset.py", line 90, in __new__
    new_class.base_filters = new_class.get_filters()
  File "/home/eyal0803/Projects/cookbook/venv/lib/python3.6/site-packages/django_filters/filterset.py", line 316, in get_filters
    filters[field_name] = cls.filter_for_reverse_field(field, field_name)
  File "/home/eyal0803/Projects/cookbook/venv/lib/python3.6/site-packages/graphene_django/filter/filterset.py", line 66, in filter_for_reverse_field
    rel = f.field.rel
AttributeError: 'ForeignKey' object has no attribute 'rel'
```


Discussion:

Resolving patch:
diff --git a/graphene_django/filter/filterset.py b/graphene_django/filter/filterset.py
--- a/graphene_django/filter/filterset.py
+++ b/graphene_django/filter/filterset.py
@@ -57,7 +57,7 @@ def filter_for_reverse_field(cls, f, name):
         Global IDs (the default implementation expects database
         primary keys)
         """
-        rel = f.field.rel
+        rel = f.field.remote_field if hasattr(f.field, 'remote_field') else f.field.rel
         default = {
             'name': name,
             'label': capfirst(rel.related_name)


Test patch: