From e51f6070df471b9d210ac1c4d52ea41b51481e70 Mon Sep 17 00:00:00 2001 From: eyal0803 Date: Thu, 22 Feb 2018 05:45:40 +0200 Subject: [PATCH 1/2] Fixes #400 After more digging than I expected (and planned), I'm 99% sure that the problem comes from `graphene_django`. I found a [comment](https://github.com/django/django/blob/16436f3751e9eec67a7b80b25c8e7d29a34be67e/django/db/models/fields/reverse_related.py#L4-L6) in Django's source that refers to an attribute named `remote_field`, instead of `rel`. It seamed to fix the problem for me without any other bugs (yet). --- graphene_django/filter/filterset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphene_django/filter/filterset.py b/graphene_django/filter/filterset.py index c716b05cd..4873f717e 100644 --- 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 default = { 'name': name, 'label': capfirst(rel.related_name) From e12c329507e9042e525c30fccc47a8d4ecc3acb0 Mon Sep 17 00:00:00 2001 From: eyal0803 Date: Fri, 23 Feb 2018 12:20:37 +0200 Subject: [PATCH 2/2] Added support for Django 1.8.x Since I didn't know why the `rel` attribute wasn't there in the first place, maybe it's better to use the `remote_field` only if it's there and leave `rel` as a default (i.e else). --- graphene_django/filter/filterset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphene_django/filter/filterset.py b/graphene_django/filter/filterset.py index 4873f717e..3d756d7ef 100644 --- 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.remote_field + rel = f.field.remote_field if hasattr(f.field, 'remote_field') else f.field.rel default = { 'name': name, 'label': capfirst(rel.related_name)