Mezzanine
を 4.1
から、4.2
へ update
したところ、
plugin
周辺で以下エラーが高確率で出力さていました。
Django1.9
では、render_to_response
に存在していた引数が、
Django1.10
のrender_to_response
では引数から削除されていたことが原因でした。
対処方法を備忘として残します。※1※2
File "/usr/local/lib/python2.7/site-packages/request/admin.py" in overview
81. }, context_instance=RequestContext(request))
Exception Type: TypeError at xxx...
Exception Value: render_to_response() got an unexpected keyword argument 'context_instance'
django-request 1.4
でのエラー抜粋になります。※2
xxx...
は、発生箇所により異なります。
前提
以下の環境で実行しています。
* OS
CentOS release 6.7 (Final)
-
Python Version
Python 2.7.8 -
Package (必要そうなものだけ抜粋)
Django (1.10.0)
Mezzanine (4.2.0)
原因
render_to_response()
のパラメータcontext_instance
がdjango 1.10
で削除されていますが、
そんなことは知らずに、context_instance
を指定しているため、エラー発生が発生しています。
Django1.9 shortcut functions では、
render_to_response()
render_to_response(template_name, context=None, context_instance=_context_instance_undefined, content_type=None, status=None, dirs=_dirs_undefined, using=None)
context_instance
が存在しますが、
Django1.10 shortcut functions では、
render_to_response()
render_to_response(template_name, context=None, content_type=None, status=None, using=None)
context_instance
が削除されています。※
※ dirs
も削除されてます。
対処方法
Django 1.8 release notes に、記載がありますが、
context_instance
を指定して、render_to_response()
を呼び出している場合は、render()
に変更すれば良いようです。
django-request
については、github
の最新版のソースコードが既に対応済だったので、対応部分をコピペしました。
以下、対応箇所の抜粋になります。
- /usr/local/lib/python2.7/site-packages/request/admin.py
5 #from django.shortcuts import render_to_response
6 from django.shortcuts import render
73 def overview(self, request):
74 qs = Request.objects.this_month()
75 for plugin in plugins.plugins:
76 plugin.qs = qs
77 # 元の記述はコメントアウト
78 #return render_to_response('admin/request/request/overview.html', {
79 # 'title': _('Request overview'),
80 # 'plugins': plugins.plugins,
81 #}, context_instance=RequestContext(request))
82
83 return render(
84 request,
85 'admin/request/request/overview.html',
86 {
87 'title': _('Request overview'),
88 'plugins': plugins.plugins,
89 }
90 )
まあ、こっちがdjango
のversion
ゴリゴリあげているのがいけないんでしょうけど、
いつ、PACKAGE INDEX
に登録されるのだろう。。
追記 (2017/07/14)
最新version の django-request をインストールすると、
上記の事象は解消されます。
django-request 1.5.1 : Python Package Index
以上です。
コメント