Add Page.get_route_paths() to support redirect creation for alternative routes

pull/7839/head
Andy Babic 2022-01-07 13:06:32 +00:00 zatwierdzone przez Matt Westcott
rodzic f3a3f38a61
commit ca3558e528
1 zmienionych plików z 22 dodań i 0 usunięć

Wyświetl plik

@ -1678,6 +1678,28 @@ class Page(AbstractPage, index.Indexed, ClusterableModel, metaclass=PageBase):
patch_cache_control(response, private=True)
return response
def get_route_paths(self):
"""
.. versionadded:: 2.16
Returns a list of paths that this page can be viewed at.
These values are combined with the dynamic portion of the page URL to
automatically create redirects when the page's URL changes.
.. note::
If using ``RoutablePageMixin``, you may want to override this method
to include the paths of popualar routes.
.. note::
Redirect paths are 'normalized' to apply consistant ordering to GET parameters,
so you don't need to include every variation. Fragment identifiers are discarded
too, so should be avoided.
"""
return ['/']
def get_cached_paths(self):
"""
This returns a list of paths to invalidate in a frontend cache