mezzanine
が 2016/08/12 に4.2
にversion up
したので、
当ブログのmezzanine
を 4.1
から4.2
にupdate
してみました。
そんなにトラブらない予想が、前にversion
上げた時に適当に修正したせいで動かなくなったので、
実施したことを備忘として残します。
0. 前提
以下の環境で実行しています。
* OS
CentOS release 6.7 (Final)
-
Python Version
Python 2.7.8 -
Package (必要そうなものだけ抜粋)
Django (1.9.6)
Mezzanine (4.1.0)
1. UPGRADE
現状Versionの確認
UPGRADE
前のpip list
[0.]の内容とも重複しますが、UPGRADE
前の構成情報になります。
pip list
------------------------------------
beautifulsoup4 (4.4.1)
bleach (1.4.2)
chardet (2.3.0)
Django (1.9.6)
django-appconf (1.0.2)
django-compressor (2.0)
django-contrib-comments (1.7.1)
django-crontab (0.7.1)
django-grappelli (2.8.1)
django-htmlmin (0.9.1)
django-request (1.4.0)
django-robots (2.0)
django-sites (0.9)
filebrowser-safe (0.4.3)
future (0.15.2)
grappelli-safe (0.4.2)
html5lib (0.9999999)
importlib (1.0.3)
Markdown (2.6.6)
Mezzanine (4.1.0)
mezzanine-pagedown (1.0)
oauthlib (1.1.1)
Pillow (3.2.0)
pip (8.1.2)
psycopg2 (2.6.1)
Pygments (2.0.2)
pytz (2016.4)
rcssmin (1.0.6)
requests (2.10.0)
requests-oauthlib (0.6.1)
rjsmin (1.0.12)
setuptools (21.0.0)
six (1.10.0)
tzlocal (1.2.2)
wheel (0.26.0)
-----------------------------------
UPGRADE
pip install Mezzanine -U
-----------------------------------
Successfully installed
Mezzanine-4.2.0
beautifulsoup4-4.5.1
bleach-1.4.3
django-1.10
django-contrib-comments-1.7.2
oauthlib-1.1.2
pillow-3.3.0
pytz-2016.6.1
requests-2.11.0
requests-oauthlib-0.6.2
-----------------------------------
2. check コマンドによる確認
django
に check
というcomammd
があるのでこれを使用して基本的な確認をします。
* はじめての Django アプリ作成、その2 | Django documentation | Django
に、
もし興味があれば python manage.py check を実行することもできます
これはマイグレーションを作成したりデータベースにふれることなくプロジェクトになんの問題がないか確認します 。
と記載がある通り、基本的なところはcheck
してくれます。
エンプラだったら、テスト環境でやるべきところだと思いますが。。
python2.7 manage.py check
実行
python2.7 manage.py check
-----------------------------------
File {$MEZZANINE_PROJECT_HOME}/urls.py", line 10, in <module>
import mezzanine_pagedown.urls
File "/usr/local/lib/python2.7/site-packages/mezzanine_pagedown/urls.py", line 1, in <module>
from django.conf.urls import patterns, url
ImportError: cannot import name patterns
-----------------------------------
mezzanine_pagedown
プラグインでエラーが出ました。
パッケージのUPGRADE
を実施してみます。
pip install mezzanine-pagedown -U
-----------------------------------
変化なし
-----------------------------------
変化がありません。
/usr/local/lib/python2.7/site-packages/mezzanine_pagedown/urls.py
で、
エラーになっていたので、対象ファイルを修正します。
Bitbucket でissue
の報告があるので、
そのうち修正されるのかと思います。
以下の通り、修正しました。
from django.conf.urls import url
from .views import MarkupPreview
urlpatterns = [
url(r'^preview/$', MarkupPreview.as_view(), name='preview'),
]
#urlpatterns = patterns('',
# url(r'^preview/$', MarkupPreview.as_view(), name='preview'),
#)
python2.7 manage.py check
再度実行
python2.7 manage.py check
-----------------------------------
File "/var/www/site/blog/blog/urls.py", line 20, in <module>
url("^xyz_monotalk_admin/backup/$", "admin_backup.views.admin_backup", name="admin_backup"),
File "/usr/local/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 85, in url
raise TypeError('view must be a callable or a list/tuple in the case of include().')
TypeError: view must be a callable or a list/tuple in the case of include().
-----------------------------------
urls.py
の記述がダメでエラーになっていました。
文字列参照ではなくて、関数参照にしないといけないです。
from admin_backup.views import admin_backup
urlpatterns = i18n_patterns(
# MEZZANINE ADMIN BACKUP
# ----------------------
#url("^admin/backup/$", "admin_backup.views.admin_backup", name="admin_backup"),
url("^admin/backup/$", admin_backup, name="admin_backup"),
# ----------------------
# Change the admin prefix here to use an alternate URL for the
# admin interface, which would be marginally more secure.
url("^admin/", include(admin.site.urls)),
)
python2.7 manage.py check
再々実行
File "/usr/local/lib/python2.7/site-packages/request/admin.py", line 63, in get_urls
return patterns('',
UnboundLocalError: local variable 'patterns' referenced before assignment
django-request (1.4.0)
でエラーです。これも url
関連でエラーです。
Github上のソースコードは既に修正済だったので、
それを拝借して対象ソース/usr/local/lib/python2.7/site-packages/request/admin.py
を、
以下の通り、修正しました。
- 1箇所目
43 def get_urls(self):
44 try:
45 from django.conf.urls import url
46 #from django.conf.urls import patterns, url
47 except ImportError:
48 # to keep backward (Django <= 1.4) compatibility
49 from django.conf.urls.defaults import patterns, url
50
- 2箇所目
return [
url(r'^overview/$', wrap(self.overview), name='%s_%s_overview' % info),
url(r'^overview/traffic/$', wrap(self.traffic), name='%s_%s_traffic' % info),
] + super(RequestAdmin, self).get_urls()
#return patterns('',
# url(r'^overview/$', wrap(self.overview), name='%s_%s_overview' % info),
# url(r'^overview/traffic.json$', wrap(self.traffic), name='%s_%s_traffic' % info),
#) + super(RequestAdmin, self).get_urls()
3. サーバー 起動後の確認
[2].のチェックでエラーは出なくなったので、
service httpd restart
を実行し画面を表示したところ、大丈夫かと思いきや、エラーが発生しました。
1つ目 テーマ内使っていたfuture
の記述を削除
Internal Server Error: /
TemplateSyntaxError at /
'future' is not a registered tag library. Must be one of:
template内の ‘future’ タグがなくなったらしく、
古いテンプレートだとエラーが出力されます。
mezzaninne 3
のを引き継いで使っているからかもしれません。
django1.9
から future
タグがなくなったようです。
future
の記載をtemplate
から軒並み削除しました。
- テーマ内使っていた
future
の記述を削除
find ./ -name *.html | xargs grep 'future'
--------------
./templates/pages/index.html:{% load pages_tags mezzanine_tags i18n future staticfiles blog_tags keyword_tags %}
./templates/pages/menus/footer.html:{% load i18n future pages_tags blog_tags keyword_tags mezzanine_tags %}
./templates/pages/menus/breadcrumb.html:{% load i18n future pages_tags %}
./templates/pages/menus/footer_tree.html:{% load i18n future pages_tags %}
./templates/pages/menus/admin.html:{% load pages_tags i18n future staticfiles %}
./templates/pages/menus/dropdown.html:{% load i18n future pages_tags mezzanine_tags%}
./templates/pages/menus/mobile.html:{% load i18n future pages_tags %}
./templates/pages/menus/tree.html:{% load i18n future pages_tags %}
./templates/pages/menus/primary.html:{% load pages_tags i18n future %}
./templates/accounts/includes/user_panel_nav.html:{% load i18n future mezzanine_tags accounts_tags %}
./templates/accounts/includes/user_panel.html:{% load i18n future mezzanine_tags accounts_tags %}
./templates/accounts/account_profile.html:{% load i18n future mezzanine_tags accounts_tags %}
./templates/accounts/account_login.html:{% load i18n future %}
./templates/includes/search_form.html:{% load mezzanine_tags i18n future %}
./templates/includes/editable_toolbar.html:{% load i18n future staticfiles %}
./templates/includes/editable_form.html:{% load i18n future %}
./templates/includes/editable_loader.html:{% load i18n future staticfiles %}
./templates/generic/includes/rating.html:{% load mezzanine_tags rating_tags i18n future %}
--------------
2つ目 No module named context_processors
でエラー
Exception Type: ImportError at /wp-login.php/
Exception Value: No module named context_processors
Request information:
USER: AnonymousUser
Upgrading templates to Django 1.8 | Django documentation | Django に、
Furthermore you should replace django.core.context_processors with django.template.context_processors in the names of context processors.
と記載されています。過去に修正した際にTEMPLATES
を辞書形式で書き直したけど、
context_processors
の名称変更はやっていなかった気がします。。
settings.py
内の、TEMPLATES
で指定している、
context_processors
の記述を以下のように変更しました。
'context_processors': (
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
#'django.core.context_processors.debug',
#'django.core.context_processors.i18n',
#'django.core.context_processors.static',
#'django.core.context_processors.media',
#'django.core.context_processors.request',
#'django.core.context_processors.tz',
"django.template.context_processors.debug",
"django.template.context_processors.i18n",
"django.template.context_processors.static",
"django.template.context_processors.media",
"django.template.context_processors.request",
"django.template.context_processors.tz",
'mezzanine.conf.context_processors.settings',
'mezzanine.pages.context_processors.page'),
これで、画面表示ができるようになりました。
Django110Warning
で警告が出た時に適用に修正した箇所で、
軒並みエラーとなった感があります。
以上です。
コメント