I'm really new to Wagtail. I've been trying to find a way to filter a the values in a chooser (PageChooserPanel). I'm building a story site where authors can create non-linear stories. I followed a blog model to build this and expanded on it. I've gotten to the point where authors can link up pages through an orderable. The problem is the orderable shows pages of other stories. Is there a way to filter out the unrelated pages. I appreciate any help on this. Thank you in advance!
Here's my code:
class StoryPath(models.Model):
route = models.ForeignKey('story.StoryPage', on_delete=models.SET_NULL, null=True, related_name='next_path', verbose_name='Story Path')
panels = [
PageChooserPanel('route', page_type='story.StoryPage'),
FieldPanel('correct'),
]
class Meta:
abstract = True
class StoryPathOrderable(Orderable, StoryPath):
page = ParentalKey('story.StoryPage', on_delete=models.CASCADE, related_name='story_paths')
class StoryPage(Page):
template = 'story/story_page.html'
body = RichTextField()
content_panels = [
FieldPanel('title', heading='Section Title', classname='collapsible'),
FieldPanel('body', classname='collapsible'),
MultiFieldPanel(
[
InlinePanel('story_paths'),
],
heading = 'Story Paths',
classname = 'collapsible'
)
]
parent_page_type =['story.Story']
subpage_types = []
def __str__(self):
return '%s' % (self.title)
class Story(Page):
subtitle = models.CharField(max_length=250, null=True, blank=True)
content_panels = Page.content_panels + [
FieldPanel('subtitle'),
]
subpage_types = ['story.StoryPage']
def __str__(self):
return '%s' % (self.title)
EDIT: Here's the template I'm using:
{% extends "base.html" %}
{% load static wagtailcore_tags %}
{% block body_class %}{{self.title}}{% endblock %}
{% block extra_css %}{% endblock extra_css %}
{% block content %}
<div class="d-flex justify-content-center flex-column">
<div class="fs-3">{{page.title}}</div>
<div>{{page.body|richtext}}</div>
</div>
{% endblock content %}