From 0f6f6501783631135dbaf29cdcae9a11927a85a1 Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Thu, 26 Oct 2017 16:26:57 +0100 Subject: [PATCH] Rename field.rel to field.remote_field --- wagtail/api/v2/serializers.py | 2 +- wagtail/contrib/modeladmin/views.py | 8 ++++---- wagtail/wagtailadmin/edit_handlers.py | 4 ++-- wagtail/wagtailcore/models.py | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/wagtail/api/v2/serializers.py b/wagtail/api/v2/serializers.py index fbb6ca2eac..64aad0e9be 100644 --- a/wagtail/api/v2/serializers.py +++ b/wagtail/api/v2/serializers.py @@ -327,7 +327,7 @@ class PageSerializer(BaseSerializer): if relation_info.to_many: model = getattr(self.Meta, 'model') child_relations = { - child_relation.field.rel.related_name: child_relation.related_model + child_relation.field.remote_field.related_name: child_relation.related_model for child_relation in get_all_child_relations(model) } diff --git a/wagtail/contrib/modeladmin/views.py b/wagtail/contrib/modeladmin/views.py index 751102c5b1..81e25c210c 100644 --- a/wagtail/contrib/modeladmin/views.py +++ b/wagtail/contrib/modeladmin/views.py @@ -308,13 +308,13 @@ class IndexView(WMABaseView): # Lookups on non-existent fields are ok, since they're ignored # later. return True - if hasattr(field, 'rel'): - if field.rel is None: + if hasattr(field, 'remote_field'): + if field.remote_field is None: # This property or relation doesn't exist, but it's allowed # since it's ignored in ChangeList.get_filters(). return True - model = field.rel.to - rel_name = field.rel.get_related_field().name + model = field.remote_field.model + rel_name = field.remote_field.get_related_field().name elif isinstance(field, ForeignObjectRel): model = field.model rel_name = model._meta.pk.name diff --git a/wagtail/wagtailadmin/edit_handlers.py b/wagtail/wagtailadmin/edit_handlers.py index ffc093dd2a..f63db6ab5a 100644 --- a/wagtail/wagtailadmin/edit_handlers.py +++ b/wagtail/wagtailadmin/edit_handlers.py @@ -555,7 +555,7 @@ class BaseChooserPanel(BaseFieldPanel): def get_chosen_item(self): field = self.instance._meta.get_field(self.field_name) - related_model = field.rel.model + related_model = field.remote_field.model try: return getattr(self.instance, self.field_name) except related_model.DoesNotExist: @@ -606,7 +606,7 @@ class BasePageChooserPanel(BaseChooserPanel): return target_models else: - return [cls.model._meta.get_field(cls.field_name).rel.to] + return [cls.model._meta.get_field(cls.field_name).remote_field.model] class PageChooserPanel(object): diff --git a/wagtail/wagtailcore/models.py b/wagtail/wagtailcore/models.py index 7115f92425..59434b09bc 100644 --- a/wagtail/wagtailcore/models.py +++ b/wagtail/wagtailcore/models.py @@ -510,7 +510,7 @@ class Page(six.with_metaclass(PageBase, AbstractPage, index.Indexed, Clusterable for field in cls._meta.fields: if isinstance(field, models.ForeignKey) and field.name not in field_exceptions: - if field.rel.on_delete == models.CASCADE: + if field.remote_field.on_delete == models.CASCADE: errors.append( checks.Warning( "Field hasn't specified on_delete action",