Django+Wagtail+CRX+Puput の移設2( - CRX1.0)

2023/02 の作業

Django+Wagtail+CRX+Puput の移設1(移設 - CRX0.25) のつづき。

各種パッケージアップデート

crx1.0.*にアップデート:

$ sudo su - work_user
$ source work_venv/bin/activate
$ pip install coderedcms==1.0.*
・・・・
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
puput 1.1.3 requires wagtail<3.0,>=2.7, but you have wagtail 3.0.3 which is incompatible.
Successfully installed coderedcms-1.0.1 django-bootstrap5-21.3 django-modelcluster-6.0 django-permissionedforms-0.1 wagtail-3.0.3 wagtail-cache-2.2.0 wagtail-seo-2.3.0


puput のエラーを見逃してて、さらに、変更リストを確認する前に、変更してしまった。

けど、更新されたみたいだ。


ファイルを更新:

$ wagtail updatemodulepaths
workesite/workesite/settings/base.py - 1 change
workesite/website/wagtail_hooks.py - 1 change
workesite/website/migrations/0001_initial.py - 6 changes
workesite/website/migrations/0002_initial_data.py - 1 change
workesite/website/migrations/0003_auto_20230202_1736.py - 6 changes
Warning - /home/work_user/work_venv/lib/python3.9/site-packages/xlwt/BIFFRecords.py is not a valid UTF-8 file. Lines with decode errors have been ignored
Warning - /home/work_user/work_venv/lib/python3.9/site-packages/xlwt/UnicodeUtils.py is not a valid UTF-8 file. Lines with decode errors have been ignored
work_venv/lib/python3.9/site-packages/wagtailimportexport/compat.py - 7 changes
work_venv/lib/python3.9/site-packages/wagtail/admin/panels.py - 5 changes
・・・・
work_venv/lib/python3.9/site-packages/puput/templatetags/puput_tags.py - 1 change

Checked 4102 .py files, 27 files updated.


puput をアップデート:

$ pip install puput==1.2.0
・・・・
Successfully installed puput-1.2.0



django もアップデート:

$ pip install -U Django==3.2.18
・・・・
Successfully installed Django-3.2.18


バージョンアップによる変更の確認


v1.0.0 release notes (https://docs.coderedcorp.com/wagtail-crx/releases/v1.0.0.html)の内容を確認しながら、カスタムテンプレート等の変更を確認

今回、自分の環境では、以下を変更

・base.py の BASE_URL を WAGTAILADMIN_BASE_URL に変更。

・GeneralSettings を LayoutSettings に変更

・リンクの codered-*.[css|js] を crx-*.[css|js] に変更

・favicon などの type を png から webp に変更

・required_scripts ブロックの削除


crx の bootstrap が 4 から 5 になったので修正:

・カスタムテンプレートで bootstrap4 をロードしているものは、django_bootstrap5 に変更。

・cdn の bootstrap の url をバージョンに合わせて変更。

・bootstrap4 では jquery を使っていたが、bootstrap5 では jquery を利用しなくなった。が、puput が bootstrap3 と古く jquery を使っているので、puput の jquery のリンクを入れる。


base.py を更新:

・・・・
INSTALLED_APPS = [
・・・・
    #'bootstrap4',
    'django_bootstrap5',
・・・・
]
・・・・
#BOOTSTRAP4 = {
#    # set to blank since coderedcms already loads jquery and bootstrap
#    'jquery_url': '',
#    'base_url': '',
#    # remove green highlight on inputs
#    'success_css_class': ''
#}
・・・・


更新をマイグレーション

マイグレーション:

$ python manage.py makemigrations --settings worksite.settings.prod
Migrations for 'website':
website/migrations/0004_auto_20230205_1651.py
- Alter field body on articleindexpage
- Alter field body on articlepage
- Alter field body on formpage
- Alter field choices on formpagefield
- Alter field default_value on formpagefield
- Alter field body on webpage
$
$ python manage.py migrate --settings worksite.settings.prod
Operations to perform:
Apply all migrations: admin, auth, coderedcms, contenttypes, puput, sessions, taggit, wagtailadmin, wagtailcore, wagtaildocs, wagtailembeds, wagtailforms, wagtailimages, wagtailredirects, wagtailsearch, wagtailseo, wagtailusers, website
Running migrations:
Applying coderedcms.0031_wagtail3... OK
Applying coderedcms.0032_accordion_accordionpanel... OK
・・・・
Applying wagtailredirects.0008_add_verbose_name_plural... OK
Applying website.0004_auto_20230205_1651... OK


最後の設定

prod.py の static、media を S3 に向ける様に元に戻す。

古いメディアファイルをいろいろする:

$ python manage.py wagtail_update_image_renditions --purge-only --settings workesite.settings.prod
Successfully purged 159 image rendition(s)


キャッシュをクリア:

$ python manage.py clear_wagtail_cache --settings workesite.settings.prod


インデックスを更新:

$ python manage.py wagtail_update_index --settings workesite.settings.prod
default: Rebuilding index default
default: website.ArticlePage
default: website.ArticleIndexPage
default: website.FormPage
default: website.WebPage           .
default: coderedcms.CoderedPage
default: wagtaildocs.Document
default: wagtailimages.Image       .
default: wagtailcore.Page          .
default: puput.BlogPage            .
default: puput.EntryPage           .
default: indexed 87 objects


アプリケーション以外のパッケージを設定


現環境と同じ様に以下のパッケージを設定


・supervisor (参考:supervisorを入れる Supervisorのプロセス停止設定 Supervisorのログ設定)

・nginx (参考:NGINXカテゴリ)

・logroate (参考:logrotateの確認 NGINXのlogrotate Supervisorのlogrotate)

・elastic (参考:EC2に固定IPを割り当てる)

・dns (参考:ドメインを割り当てる)

・hostname (参考:NGINXとDjangoのホスト名を設定)

・letsendrypt (参考:Let's Encrypt カテゴリ)


これで、同じように https://ドメイン名 でアクセスできる様になる。

おしまい。