Merge pull request #245 from edmorley/fix-deprecation-warnings

Remove usages of deprecated field.rel
This commit is contained in:
Syrus Akbary 2017-09-01 00:46:21 -07:00 committed by GitHub
commit 992fbf0c44
2 changed files with 4 additions and 11 deletions

View File

@ -10,7 +10,7 @@ from graphql import assert_valid_name
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 convert_onetoone_field_to_djangomodel(field, registry=None):
@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 convert_field_to_list_or_connection(field, registry=None):
@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)

View File

@ -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)