2
1

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チュートリアル 2 ホームページを始めよう

Last updated at Posted at 2019-08-25

#Wagtail チュートリアル 2
<=1 Wagtailをインストールしよう
=>3 バナーを追加しよう(1)
##ホームページを始めよう

0,1,3,4,6,7

home/models.py

from django.db import models #⓪ モデルをインポート

from wagtail.core.models import Page #⓪ページをインポート
from wagtail.admin.edit_handlers import FieldPanel #④ FieldPanelをインポート


class HomePage(Page):#⓪ページを引数に
    
    templates = "home/home_page.html" #① wagtailtutorial/templates/home/home_page.html
    
    max_count = 1 #⑥ ADD CHILD PAGEを制限

    banner_title = models.CharField(max_length=100, blank=False, null=True) #③ banner_titleを定義

    content_panels = Page.content_panels + [ #④ admin画面にbanner_titleを追加
        FieldPanel("banner_title")
    ]

    class Meta:
    
        #verbose_name = "OH HELLO WORLD" ⑦ ADD CHILD PAGEでの表記
        verbose_name = "Home Page"
        verbose_name_plural = "Home Pages"

2,5

wagtailtutorial/templates/home/home_page.html

{% block content %} <!--② base.htmlから引っ張り出す-->
    <!--② Helloworld -->
    {{self.banner_title}} <!--⑤banner_titleを表示-->
{% endblock %}


スクリーンショット 2019-08-26 08.12.57.png

スクリーンショット 2019-08-26 08.19.49.png

スクリーンショット 2019-08-26 08.21.19.png

スクリーンショット 2019-08-26 08.28.57.png

2
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?