Use class name rather than database name for body classes

This avoids duplication and makes the classnames a bit shorter, and more sane.
This commit is contained in:
Jake Howard 2022-07-25 19:30:47 +01:00
parent ba7a2d7b4d
commit 71c08f5568
Signed by: jake
GPG key ID: 57AFB45680EDD477
2 changed files with 3 additions and 2 deletions

View file

@ -1,4 +1,4 @@
body.page-home-homepage {
body.page-homepage {
main {
background-repeat: no-repeat;
background-size: cover;

View file

@ -4,6 +4,7 @@ from typing import Any, Optional
from django.db import models
from django.http.request import HttpRequest
from django.utils.functional import cached_property, classproperty
from django.utils.text import slugify
from wagtail.admin.panels import FieldPanel
from wagtail.fields import StreamField
from wagtail.images import get_image_model_string
@ -26,7 +27,7 @@ class BasePage(Page):
@classproperty
def body_class(cls) -> str:
return "page-" + cls._meta.db_table.replace("_", "-")
return "page-" + slugify(cls.__name__)
def get_parent_pages(self) -> PageQuerySet:
"""