Skip to content

Commit 2168d3d

Browse files
committed
Fixed minor bug with the type resolver of the ManyToMany fields on Django models.
1 parent b8a661a commit 2168d3d

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

graphene_django_extras/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from .paginations import LimitOffsetGraphqlPagination, PageGraphqlPagination, CursorGraphqlPagination
1010
from .types import DjangoObjectType, DjangoInputObjectType, DjangoListObjectType, DjangoSerializerType
1111

12-
VERSION = (0, 4, 2, 'final', '')
12+
VERSION = (0, 4, 3, 'final', '')
1313

1414
__version__ = get_version(VERSION)
1515

graphene_django_extras/utils.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,15 @@
1717

1818

1919
def get_reverse_fields(model):
20-
for name, attr in model.__dict__.items():
20+
reverse_fields = {
21+
f.name: f for f in model._meta.get_fields()
22+
if f.auto_created and not f.concrete
23+
}
24+
25+
for name, field in reverse_fields.items():
2126
# Django =>1.9 uses 'rel', django <1.9 uses 'related'
22-
related = getattr(attr, 'rel', None) or \
23-
getattr(attr, 'related', None)
27+
related = getattr(field, 'rel', None) or \
28+
getattr(field, 'related', None)
2429
if isinstance(related, ManyToOneRel):
2530
yield (name, related)
2631
elif isinstance(related, ManyToManyRel) and not related.symmetrical:
@@ -93,7 +98,7 @@ def get_model_fields(model):
9398

9499
def get_obj(app_label, model_name, object_id):
95100
"""
96-
Function used by my to get objst
101+
Function used to get a object
97102
:param app_label: A valid Django Model or a string with format: <app_label>.<model_name>
98103
:param model_name: Key into kwargs that contains de data: new_person
99104
:param object_id:

0 commit comments

Comments
 (0)