From 004408a9e8621cfb283ada0d5d533a11c34a00d7 Mon Sep 17 00:00:00 2001 From: Justin Plock Date: Fri, 5 Feb 2016 14:17:07 -0500 Subject: [PATCH] Attempt to address Django 1.9 deprecate warnings related to field.rel --- rest_framework/utils/model_meta.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/rest_framework/utils/model_meta.py b/rest_framework/utils/model_meta.py index f151c6f36..253cd5bcc 100644 --- a/rest_framework/utils/model_meta.py +++ b/rest_framework/utils/model_meta.py @@ -80,16 +80,16 @@ def get_field_info(model): def _get_pk(opts): pk = opts.pk - while pk.rel and pk.rel.parent_link: + while pk.remote_field and pk.remote_field.parent_link: # If model is a child via multi-table inheritance, use parent's pk. - pk = pk.rel.to._meta.pk + pk = pk.remote_field.to._meta.pk return pk def _get_fields(opts): fields = OrderedDict() - for field in [field for field in opts.fields if field.serialize and not field.rel]: + for field in [field for field in opts.fields if field.serialize and not field.remote_field]: fields[field.name] = field return fields @@ -104,10 +104,10 @@ def _get_forward_relationships(opts): Returns an `OrderedDict` of field names to `RelationInfo`. """ forward_relations = OrderedDict() - for field in [field for field in opts.fields if field.serialize and field.rel]: + for field in [field for field in opts.fields if field.serialize and field.remote_field]: forward_relations[field.name] = RelationInfo( model_field=field, - related_model=_resolve_model(field.rel.to), + related_model=_resolve_model(field.remote_field.to), to_many=False, to_field=_get_to_field(field), has_through_model=False @@ -117,12 +117,12 @@ def _get_forward_relationships(opts): for field in [field for field in opts.many_to_many if field.serialize]: forward_relations[field.name] = RelationInfo( model_field=field, - related_model=_resolve_model(field.rel.to), + related_model=_resolve_model(field.remote_field.to), to_many=True, # manytomany do not have to_fields to_field=None, has_through_model=( - not field.rel.through._meta.auto_created + not field.remote_field.through._meta.auto_created ) ) @@ -144,7 +144,7 @@ def _get_reverse_relationships(opts): reverse_relations[accessor_name] = RelationInfo( model_field=None, related_model=related, - to_many=relation.field.rel.multiple, + to_many=relation.field.remote_field.multiple, to_field=_get_to_field(relation.field), has_through_model=False ) @@ -160,8 +160,8 @@ def _get_reverse_relationships(opts): # manytomany do not have to_fields to_field=None, has_through_model=( - (getattr(relation.field.rel, 'through', None) is not None) and - not relation.field.rel.through._meta.auto_created + (getattr(relation.field.remote_field, 'through', None) is not None) and + not relation.field.remote_field.through._meta.auto_created ) )