2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Wagtailチュートリアル 15 adminページにSUBSCRIBERを追加

Last updated at Posted at 2019-08-30

#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)

34
スクリーンショット 2019-08-30 14.10.33.png

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?