#Wagtailチュートリアル 6
<=6 Bootstrap4 を追加しよう
=>8 blocks.pyで新しいフィールドを作る(1)
##新しいページを追加しよう
python3 manage.py startapp flex
flexフォルダができる
16
wagtailtutorial/settings/base.py
.......
INSTALLED_APPS = [
'home',
'search',
# 16 flexを追加
'flex',
'wagtail.contrib.forms',
'wagtail.contrib.redirects',
'wagtail.embeds',
'wagtail.sites',
'wagtail.users',
'wagtail.snippets',
'wagtail.documents',
'wagtail.images',
'wagtail.search',
'wagtail.admin',
'wagtail.core',
'modelcluster',
'taggit',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
.......
16
flex/models.py
from django.db import models
# 16 モデルに必要なものをインポート
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.core.models import Page
# 16 モデルを定義
class FlexPage(Page):
template = "flex/flex_page.html"
subtitle = models.CharField(max_length=100, null=True, blank=True)
content_panels = Page.content_panels + [
FieldPanel("subtitle"),
]
class Meta:
verbose_name = "Flex Page"
verbose_name_plural = "Flex Pages"
17
wagtailtutorial/templates/flex/flex_page.html
{% extends "base.html" %}
{% block content %}
{{self.subtitle}} is the subtitle {# 17 flexページのsubtitleを表示#}
{% endblock %}