Skip to content

Commit

Permalink
Handle configurable comments relation (Wagtail 2.15 fix)
Browse files Browse the repository at this point in the history
The 'comments' relation on Page will be renamed to 'wagtail_admin_comments' in Wagtail 2.15, as per wagtail/wagtail#7591, and 2.13.5 / 2.14.2 will allow developers to 'opt in' to the new name to prevent conflicts with third-party packages that also use the name 'comments' (wagtail/wagtail#7600 / wagtail/wagtail#7601). We therefore need to recognise the relation name in use, rather than hard-coding 'comments'.
  • Loading branch information
gasman committed Oct 14, 2021
1 parent 8ee52c8 commit ad5f385
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion wagtail_localize/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
from wagtail.core.fields import RichTextField, StreamField
from wagtail.core.models import Page, TranslatableMixin

try:
from wagtail.core.models import COMMENTS_RELATION_NAME
except ImportError:
COMMENTS_RELATION_NAME = 'comments'


class BaseTranslatableField:
def __init__(self, field_name):
Expand Down Expand Up @@ -170,7 +175,7 @@ def get_translatable_fields(model):
if issubclass(model, ClusterableModel):
for child_relation in get_all_child_relations(model):
# Ignore comments
if issubclass(model, Page) and child_relation.name == 'comments':
if issubclass(model, Page) and child_relation.name == COMMENTS_RELATION_NAME:
continue

if issubclass(child_relation.related_model, TranslatableMixin):
Expand Down

0 comments on commit ad5f385

Please sign in to comment.