Created
July 21, 2018 18:38
-
-
Save KalobTaulien/bbc1d88ec9d9d3f1640b4e8e05032dc7 to your computer and use it in GitHub Desktop.
Wagtail 2: How to limit one page type per site.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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