#Wagtailチュートリアル 15
<=14 SNSをうめこもう
=>16 親ページと子ページ
##adminページにSUBSCRIBERを追加
34
python3 startapp subscribers
wagtailtutrial/settings/base.py
INSTALLED_APPS = [
"home",
"search",
# 16 flexを追加
"flex",
# 18 streamsを追加
"streams",
# 32 追加
"site_settings",
"subscribers", # 34 追加
"wagtail.contrib.modeladmin", # 34 追加
"wagtail.contrib.forms",
"wagtail.contrib.redirects",
"wagtail.contrib.settings", # 32 追加
"wagtail.embeds",
"wagtail.sites",
........
subscribers/models.py
from django.db import models
# 34 Djangoの感じで定義
class Subscribers(models.Model):
email = models.CharField(
max_length=100, blank=False, null=False, help_text="Email address"
)
full_name = models.CharField(
max_length=100, blank=False, null=False, help_text="First and last name"
)
def __str__(self):
return self.full_name
class Meta:
verbose_name = "Susbcriber"
verbose_name_plural = "Subscribers"
subscribers/admin.py
# 34 定義
from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register
from .models import Subscribers
class SubscriberAdmin(ModelAdmin):
"""Subscriber admin."""
model = Subscribers
menu_label = "Susbcribers"
menu_icon = "placeholder"
menu_order = 290
add_to_settings_menu = False
exclude_from_explorer = False
list_display = ("email", "full_name")
search_fields = ("email", "full_name")
modeladmin_register(SubscriberAdmin)