mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-01-30 19:24:08 +03:00
Merge pull request #245 from edmorley/fix-deprecation-warnings
Remove usages of deprecated field.rel
This commit is contained in:
commit
992fbf0c44
|
@ -10,7 +10,7 @@ from graphql import assert_valid_name
|
||||||
|
|
||||||
from .compat import ArrayField, HStoreField, JSONField, RangeField
|
from .compat import ArrayField, HStoreField, JSONField, RangeField
|
||||||
from .fields import DjangoListField, DjangoConnectionField
|
from .fields import DjangoListField, DjangoConnectionField
|
||||||
from .utils import get_related_model, import_single_dispatch
|
from .utils import import_single_dispatch
|
||||||
|
|
||||||
singledispatch = 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)
|
@convert_django_field.register(models.OneToOneRel)
|
||||||
def convert_onetoone_field_to_djangomodel(field, registry=None):
|
def convert_onetoone_field_to_djangomodel(field, registry=None):
|
||||||
model = get_related_model(field)
|
model = field.related_model
|
||||||
|
|
||||||
def dynamic_type():
|
def dynamic_type():
|
||||||
_type = registry.get_type_for_model(model)
|
_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.ManyToManyRel)
|
||||||
@convert_django_field.register(models.ManyToOneRel)
|
@convert_django_field.register(models.ManyToOneRel)
|
||||||
def convert_field_to_list_or_connection(field, registry=None):
|
def convert_field_to_list_or_connection(field, registry=None):
|
||||||
model = get_related_model(field)
|
model = field.related_model
|
||||||
|
|
||||||
def dynamic_type():
|
def dynamic_type():
|
||||||
_type = registry.get_type_for_model(model)
|
_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.OneToOneField)
|
||||||
@convert_django_field.register(models.ForeignKey)
|
@convert_django_field.register(models.ForeignKey)
|
||||||
def convert_field_to_djangomodel(field, registry=None):
|
def convert_field_to_djangomodel(field, registry=None):
|
||||||
model = get_related_model(field)
|
model = field.related_model
|
||||||
|
|
||||||
def dynamic_type():
|
def dynamic_type():
|
||||||
_type = registry.get_type_for_model(model)
|
_type = registry.get_type_for_model(model)
|
||||||
|
|
|
@ -56,13 +56,6 @@ def get_model_fields(model):
|
||||||
return all_fields
|
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):
|
def is_valid_django_model(model):
|
||||||
return inspect.isclass(model) and issubclass(model, models.Model)
|
return inspect.isclass(model) and issubclass(model, models.Model)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user