Description
djangocms-versioning implements a set of redirects after a version state change, e.g., redirect to the published version after publishing.
Depending on the site setup, those redirects might fail, e.g. when publishing a child page of an app hooked page. The app hook "swallows" all URLs below its own, and a redirect to the just published page fails with a 404.
djangocms-versioning should first check, if the redirect URLs are reversible and, if not, implement a fallback solution.
Affected IMHO are two instances:
- "Free" redirects like here:
- Published redirects like here (since technically the result of
get_absolute_url
is not guaranteed to be resolvable):djangocms-versioning/djangocms_versioning/admin.py
Lines 1055 to 1057 in c9bf9f4
As a fallback, I suggest using the preview URL if conf.ON_PUBLISH_REDIRECT in ("preview", "published")
, otherwise the version list url.
To check if the URL is valid, resolve
can be used:
try:
resolve(url)
except Resolver404:
url = fallback