0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-30 01:46:24 +01:00

Utilise Page._get_relevant_site_root_paths in autocreate_redirects_on_slug_change()

This commit is contained in:
Andy Babic 2022-01-10 23:53:28 +00:00 committed by Matt Westcott
parent 90cd321ec9
commit f9bee8fb02

View File

@ -39,10 +39,9 @@ def autocreate_redirects_on_slug_change(
return None
# Determine sites to create redirects for
sites = Site.objects.exclude(root_page=instance).filter(id__in=[
option.site_id for option in instance._get_site_root_paths(request=instance)
if instance.url_path.startswith(option.root_path)
])
sites = Site.objects.filter(id__in=[
option.site_id for option in instance._get_relevant_site_root_paths(cache_object=instance)
]).exclude(root_page=instance)
create_redirects(page=instance, page_old=instance_before, sites=sites)