website/website/common/models.py

20 lines
497 B
Python
Raw Normal View History

2022-06-14 20:57:43 +01:00
from django.db import models
from django.utils.functional import classproperty
2022-06-14 20:57:43 +01:00
from wagtail.admin.panels import FieldPanel
from wagtail.models import Page
class BasePage(Page):
class Meta:
abstract = True
2022-06-10 15:54:31 +01:00
@classproperty
2022-06-12 15:17:28 +01:00
def body_class(cls) -> str:
2022-06-10 16:22:20 +01:00
return "page-" + cls._meta.db_table.replace("_", "-")
2022-06-14 20:57:43 +01:00
class ContentPage(BasePage):
subtitle = models.CharField(max_length=255, blank=True)
content_panels = BasePage.content_panels + [FieldPanel("subtitle")]