I am using a page model 'EventPage', which shall have a slug based on the id of the page. To achieve this, I have modified the full_clean
method like this (similar to this question):
class EventPage(Page):
...
def full_clean(self, *args, **kwargs):
super().full_clean(*args, **kwargs)
# set slug to id, if already existing
if self.id is not None:
self.slug = str(self.id)
This seems to work fine in principle. However, after the page is published,the Wagtail admin/pages view shows a message box at the top ('Page ... created and published') with a View live
button that links to the wrong url (i.e. using the default slug created from the page title).
In the list of pages below that, the just created page's own View live
and Add child page
links show the correct page url using the page id. It is just the message box's View live
url at the top that needs to be corrected. Here's a screenshot:
How can I get the correct link in the message box at the top as well?
In case it matters, I am currently using Wagtail 2.9, Django 2.2.9 and Python 3.6.
I guess my problem has something to do with the fact that the page id is not known until the page is saved for the first time, and the View live
link in the message box somehow uses an initial page.url which is overridden later on.
Any ideas how to solve this?