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

Provide clarification on specific page usage for autocreate_redirects_on_slug_change()

This commit is contained in:
Andy Babic 2022-01-21 12:13:18 +00:00 committed by Matt Westcott
parent 9cf5e491ef
commit 5fc75b312a
2 changed files with 5 additions and 1 deletions

View File

@ -35,6 +35,9 @@ def autocreate_redirects_on_slug_change(
instance: Page,
**kwargs
):
# NB: `page_slug_changed` provides specific page instances,
# so we do not need to 'upcast' them for create_redirects here
if not getattr(settings, "WAGTAILREDIRECTS_AUTO_CREATE", True):
return None

View File

@ -493,7 +493,8 @@ class Page(AbstractPage, index.Indexed, ClusterableModel, metaclass=PageBase):
# Basically: If update_fields has been specified, and slug is not included, skip this step
if not ('update_fields' in kwargs and 'slug' not in kwargs['update_fields']):
# see if the slug has changed from the record in the db, in which case we need to
# update url_path of self and all descendants
# update url_path of self and all descendants. Even though we might not need it,
# the specific page is fetched here for sending to the 'page_slug_changed' signal.
old_record = Page.objects.get(id=self.id).specific
if old_record.slug != self.slug:
self.set_url_path(self.get_parent())