ブログを放置していて、Release v5.0.0-alpha.1 · stephenmcd/mezzanine がリリースされていたのに気づかずにいました。alphaというのが気になりますが、Django 1.x のままでいるのもセキュリティ的にリスクがあると思いましたので、思い切って更新しようかと思います。
更新時に起こったエラー、実施したことを記載します。
前提
以下の環境で実施しています。
- OS
cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
- Python Version
python3.6 -V
Python 3.6.7
- Package
python3.6 -m pip list | grep Django
Django 1.11.20
python3.6 -m pip list | grep Mezzanine
Mezzanine 4.3.1
Upgrade
-
現状 Version の確認
UPGRADE 前の pip listの結果です。
python3.6 -m pip list Package Version -------------------------- --------- beautifulsoup4 4.7.1 bleach 3.1.0 cachetools 3.1.0 certifi 2019.3.9 chardet 3.0.4 coreapi 2.3.3 coreschema 0.0.4 cssmin 0.2.0 Django 1.11.20 django-appconf 1.0.3 django-contrib-comments 1.9.1 django-cookies-samesite 0.2.0 django-critical 0.1.1 django-crontab 0.7.1 django-csp 3.5 django-csp-reports 1.2 django-extensions 2.1.6 django-filter 2.1.0 django-geoip2-extras 1.1.2 django-guess 0.0.1 django-health-check 3.12.1 django-htmlmin 0.11.0 django-oauth-toolkit 1.1.3 django-recaptcha 2.0.6 django-request 1.5.4 django-rest-swagger 2.2.0 django-robots 3.1.0 django-webpack-loader 0.6.0 djangorestframework 3.9.2 filebrowser-safe 0.5.0 future 0.17.1 geoip2 2.9.0 get 2019.4.13 google-api-python-client 1.7.8 google-auth 1.6.3 google-auth-httplib2 0.0.3 Google2Pandas 0.1.1 grappelli-safe 0.5.2 html5lib 1.0.1 httplib2 0.12.3 idna 2.8 itypes 1.1.0 Jinja2 2.10.1 Markdown 3.1 MarkupSafe 1.1.1 maxminddb 2.0.2 mecab-python3 0.996.2 Mezzanine 4.3.1 mezzanine-api 0.7.1 mezzanine-pagedown 1.3 mezzanine-pubsubhubbub-pub 0.0.5 mock 2.0.0 numpy 1.16.3 oauth2client 4.1.3 oauthlib 3.0.1 openapi-codec 1.3.2 pandas 0.24.2 pbr 5.1.3 Pillow 6.0.0 pip 20.3.3 post 2019.4.13 psutil 5.7.2 psycopg2 2.8.2 public 2019.4.13 pyasn1 0.4.5 pyasn1-modules 0.2.5 Pygments 2.3.1 pymdown-extensions 6.0 python-dateutil 2.8.0 python-memcached 1.59 pytz 2019.1 query-string 2019.4.13 request 2019.4.13 requests 2.21.0 requests-oauthlib 1.2.0 rsa 4.0 scikit-learn 0.20.3 scipy 1.2.1 setuptools 39.0.1 simplejson 3.16.0 six 1.12.0 soupsieve 1.9.1 tzlocal 1.5.1 uritemplate 3.0.0 urllib3 1.24.2 webencodings 0.5.1
- UPGRADE実行
python3.6 -m pip install Mezzanine -U Requirement already satisfied: Mezzanine in /var/www/python-venv/blog/.venv/lib/python3.6/site-packages (4.3.1) Requirement already satisfied: django<1.12,>=1.8 in /var/www/python-venv/blog/.venv/lib/python3.6/site-packages (from Mezzanine) (1.11.20) Requirement already satisfied: requests>=2.1.0 in /var/www/python-venv/blog/.venv/lib/python3.6/site-packages (from Mezzanine) (2.21.0) Requirement already satisfied: bleach>=2.0 in /var/www/python-venv/blog/.venv/lib/python3.6/site-packages (from Mezzanine) (3.1.0) Requirement already satisfied: future>=0.9.0 in /var/www/python-venv/blog/.venv/lib/python3.6/site-packages (from Mezzanine) (0.17.1) Requirement already satisfied: grappelli-safe>=0.5.0 in /var/www/python-venv/blog/.venv/lib/python3.6/site-packages (from Mezzanine) (0.5.2) Requirement already satisfied: django-contrib-comments in /var/www/python-venv/blog/.venv/lib/python3.6/site-packages (from Mezzanine) (1.9.1) Requirement already satisfied: beautifulsoup4>=4.5.3 in /var/www/python-venv/blog/.venv/lib/python3.6/site-packages (from Mezzanine) (4.7.1) Requirement already satisfied: pillow in /var/www/python-venv/blog/.venv/lib/python3.6/site-packages (from Mezzanine) (6.0.0) Requirement already satisfied: requests-oauthlib>=0.4 in /var/www/python-venv/blog/.venv/lib/python3.6/site-packages (from Mezzanine) (1.2.0) Requirement already satisfied: tzlocal>=1.0 in /var/www/python-venv/blog/.venv/lib/python3.6/site-packages (from Mezzanine) (1.5.1) Requirement already satisfied: chardet in /var/www/python-venv/blog/.venv/lib/python3.6/site-packages (from Mezzanine) (3.0.4) Requirement already satisfied: filebrowser-safe>=0.5.0 in /var/www/python-venv/blog/.venv/lib/python3.6/site-packages (from Mezzanine) (0.5.0) Requirement already satisfied: soupsieve>=1.2 in /var/www/python-venv/blog/.venv/lib/python3.6/site-packages (from beautifulsoup4>=4.5.3->Mezzanine) (1.9.1) Requirement already satisfied: six>=1.9.0 in /var/www/python-venv/blog/.venv/lib/python3.6/site-packages (from bleach>=2.0->Mezzanine) (1.12.0) Requirement already satisfied: webencodings in /var/www/python-venv/blog/.venv/lib/python3.6/site-packages (from bleach>=2.0->Mezzanine) (0.5.1) Requirement already satisfied: pytz in /var/www/python-venv/blog/.venv/lib/python3.6/site-packages (from django<1.12,>=1.8->Mezzanine) (2019.1) Requirement already satisfied: idna<2.9,>=2.5 in /var/www/python-venv/blog/.venv/lib/python3.6/site-packages (from requests>=2.1.0->Mezzanine) (2.8) Requirement already satisfied: certifi>=2017.4.17 in /var/www/python-venv/blog/.venv/lib/python3.6/site-packages (from requests>=2.1.0->Mezzanine) (2019.3.9) Requirement already satisfied: urllib3<1.25,>=1.21.1 in /var/www/python-venv/blog/.venv/lib/python3.6/site-packages (from requests>=2.1.0->Mezzanine) (1.24.2) Requirement already satisfied: oauthlib>=3.0.0 in /var/www/python-venv/blog/.venv/lib/python3.6/site-packages (from requests-oauthlib>=0.4->Mezzanine) (3.0.1)
- check コマンドによる確認
Django の check コマンド エラーとならないか確認します。
python3.6 manage.py check System check identified no issues (0 silenced).
- Makemigrations の実行
makemigrations を実行します。
python3.6 manage.py makemigrations Migrations for 'request': /var/www/python-venv/blog/.venv/lib64/python3.6/site-packages/request/migrations/0006_auto_20201223_0029.py - Alter field method on request
- migrate の実行
python3.6 manage.py migrate Operations to perform: Apply all migrations: admin, auth, blog, conf, contenttypes, core, cspreports, django_comments, forms, galleries, generic, guess, pages, redirects, request, robots, sessions, sites, twitter Running migrations: Applying request.0006_auto_20201223_0029... OK
- migrationファイルの中身
HTTPリクエストのメソッド名の長さが変わったようです。
CONNECT
、OPTIONS
が7文字あるので、それを設定したいのかなと思います。# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2020-12-22 15:29 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('request', '0005_alter_request_user'), ] operations = [ migrations.AlterField( model_name='request', name='method', field=models.CharField(default='GET', max_length=7, verbose_name='method'), ), ]
- サーバ起動後の確認
サーバーを起動して挙動を確認してみます。
apachectl restart
起動後に画面確認をしたところ、無事表示できました。
Release v5.0.0-alpha.1 · stephenmcd/mezzanine を見ると、破壊的変更もありビクビクしてましたが、問題なくアップグレードできました。
以上です。
コメント