I'm using Django 2.0 with the latest version of Wagtail CMS. I am pretty new to Wagtail and I am trying to query the children of EventIndexPage which is EventPage and have them appear on my HomePage.
I am trying to use this line of python in home app models.py below:
special_events = EventIndexPage.objects.descendant_of(inclusive=False)
But It returns:
return getattr(self.get_queryset(), name)(*args, **kwargs)
TypeError: descendant_of() missing 1 required positional argument: 'other'
When I try putting "EventPage" in before "inclusive=false" I get a type error because its an array not an integer.
docs: http://docs.wagtail.io/en/v2.0/reference/pages/queryset_reference.html
Models.py of the home app:
from django.db import models
from event.models import EventIndexPage
from wagtail.core.models import Page
from wagtail.core.fields import RichTextField
from wagtail.admin.edit_handlers import FieldPanel
class HomePage(Page):
body = RichTextField(blank=True)
special_events = EventIndexPage.objects.descendant_of(inclusive=False)
content_panels = Page.content_panels + [
FieldPanel('body', classname="full"),
]
Models.py of event app
from django.db import models
from wagtail.core.models import Page
from wagtail.core.fields import RichTextField
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.search import index
class EventIndexPage(Page):
intro = RichTextField(blank=True)
content_panels = Page.content_panels + [
FieldPanel('intro', classname="full")
]
class EventPage(Page):
date = models.DateField("Post date")
intro = models.CharField(max_length=250)
body = RichTextField(blank=True)
search_fields = Page.search_fields + [
index.SearchField('intro'),
index.SearchField('body'),
]
content_panels = Page.content_panels + [
FieldPanel('date'),
FieldPanel('intro'),
FieldPanel('body', classname="full"),
]