MMM
MMM

Reputation: 7310

How to create a custom, dynamic permalink/path for pages in Wagtail?

I am trying to define custom permalinks for my Wagtail pages.

I use the following code in my model:

def get_url_parts(self, request):
    site_id, root_url, _ = super().get_url_parts(request)
    return (
        site_id,
        root_url,
        f"/{self.date.year}/{self.date.month}/{self.slug}",
    )

According to the documentation, that should be enough. The code {% pageurl post %} returns what I am expecting (e.g. /2024/10/this-is-a-post) but the page itself returns a 404. What else do I need to do? I can't find anything anywhere saying I need to change anything in urls.py.

Upvotes: 0

Views: 14

Answers (0)

Related Questions