5👍
✅
In Wagtail, page URLs are formed from the list of slugs of the page’s parent and ancestor pages, based on the page’s position in the tree – the developer doesn’t specify them directly. So, to get the URL /posts/awesome-first-post/
, create a page with the slug posts
(usually you’d create a dedicated PostIndexPage
page model to serve as a listing page), and create the page awesome-first-post
as a child of that one (by clicking the ‘+’ icon next to the Posts page in the explorer listing view).
If you want to make sure that users only ever create PostPage
s as children of the PostIndexPage
, use a subpage_types
/ parent_page_types
setting, for example:
class PostPage(Page):
# ...
parent_page_types = ['PostIndexPage']
Source:stackexchange.com