Limit HomePage via parent_page_types to be only available as direct child of root
Try this:
parent_page_types = ['wagtailcore.Page']
also, for completeness, to allow only one instance of a Homepage, add this classmethod to your HomePage
:
@classmethod
def can_create_at(cls, parent):
# You can only create one of these!
return super(HomePage, cls).can_create_at(parent) \
and not cls.objects.exists()
First of all, thumbs up for @Serafeim answer, but I will post my answer for people searching for issue similar to mine.
I wanted to achieve the same thing but for a specifi parent in multi-site mode. Meaning I wanted to have multiple site "HomePage" but each "HomePage" can only include one "SearchIndexPage". So the above answer would be modified to
@classmethod
def can_create_at(cls, parent):
# You can only create one of these!
return super(SearchIndexPage, cls).can_create_at(parent) \
and parent.get_children().type(SearchIndexPage).count() == 0