Skip to content

Instantly share code, notes, and snippets.

@KalobTaulien
Created July 21, 2018 18:38
Show Gist options
  • Save KalobTaulien/bbc1d88ec9d9d3f1640b4e8e05032dc7 to your computer and use it in GitHub Desktop.
Save KalobTaulien/bbc1d88ec9d9d3f1640b4e8e05032dc7 to your computer and use it in GitHub Desktop.
Wagtail 2: How to limit one page type per site.
from wagtail.core.models import Page
class YourPage(Page):
"""Your Wagtail Page Type."""
template = "templates/home_page.html"
@classmethod
def can_create_at(cls, parent):
"""You can only create one of these."""
return super().can_create_at(parent) and not cls.objects.exists()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment