wagtail 比较修订产生:render() 得到了一个意外的关键字参数 'context'
wagtail comparing revisions produces : render() got an unexpected keyword argument 'context'
在 1.9 版本上,尝试在本地比较页面新功能的修订,当:
render() got an unexpected keyword argument 'context'
Request Method: GET
Request URL: http://localhost:8000/admin/pages/48/revisions/compare/488...489/
Django Version: 1.10.5
Exception Type: TypeError
Exception Value:
render() got an unexpected keyword argument 'context'
Exception Location: /usr/local/lib/python2.7/site- packages/wagtail/wagtailcore/blocks/base.py in render, line 442
Python Executable: /usr/local/bin/python2
Python Version: 2.7.13
Python Path:
['/code',
'/usr/local/bin',
'/usr/local/lib/python27.zip',
'/usr/local/lib/python2.7',
'/usr/local/lib/python2.7/plat-linux2',
'/usr/local/lib/python2.7/lib-tk',
'/usr/local/lib/python2.7/lib-old',
'/usr/local/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/site-packages']
Server time: Thu, 23 Feb 2017 14:51:34 +0000
Error during template rendering
In template /usr/local/lib/python2.7/site- packages/wagtail/wagtailadmin/templates/wagtailadmin/pages/revisions/comp are.html, error at line 37
render() got an unexpected keyword argument 'context'
27 </thead>
28
29 <tbody>
30 {% for comp in comparison %}
31 <tr>
32 <td class="title" valign="top">
33 <h2>{{ comp.field_label }}:</h2>
34 </td>
35 <td class="comparison{% if not comp.is_field %} no-padding{% endif %}">
36 {% if comp.is_field %}
37 {{ comp.htmldiff }}
38 {% elif comp.is_child_relation %}
39 {% for child_comp in comp.get_child_comparisons %}
40 <div class="comparison__child-object {% if child_comp.is_addition %}addition{% elif child_comp.is_deletion %}deletion{% endif %}">
41 {% with child_comp.get_position_change as move %}
42 {% if move %}
43 <div class="help- block help-info">
44 <p>
45 {% if move > 0 %}
46 {% blocktrans count counter=move %}
47 Moved down 1 place.
Traceback Switch to copy-and-paste view
/usr/local/lib/python2.7/site-packages/django/core/handlers/exception.py in inner
response = get_response(request) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py in _legacy_get_response
response = self._get_response(request) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py in _get_response
response = self.process_exception_by_middleware(e, request) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs) ...
▶ Local vars
/usr/local/lib/python2.7/site- packages/django/views/decorators/cache.py in _cache_controlled
response = viewfunc(request, *args, **kw) ...
▶ Local vars
/usr/local/lib/python2.7/site- packages/wagtail/wagtailadmin/decorators.py in decorated_view
return view_func(request, *args, **kwargs) ...
▶ Local vars
/usr/local/lib/python2.7/site- packages/wagtail/wagtailadmin/views/pages.py in revisions_compare
'comparison': comparison, ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/shortcuts.py in render
content = loader.render_to_string(template_name, context, request, using=using) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/loader.py in render_to_string
return template.render(context, request) ...
▶ Local vars
/usr/local/lib/python2.7/site- packages/django/template/backends/django.py in render
return self.template.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render
return self._render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in _render
return self.nodelist.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render
bit = node.render_annotated(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render_annotated
return self.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/loader_tags.py in render
return compiled_parent._render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in _render
return self.nodelist.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render
bit = node.render_annotated(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render_annotated
return self.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/loader_tags.py in render
return compiled_parent._render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in _render
return self.nodelist.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render
bit = node.render_annotated(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render_annotated
return self.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/loader_tags.py in render
return compiled_parent._render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in _render
return self.nodelist.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render
bit = node.render_annotated(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render_annotated
return self.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/loader_tags.py in render
result = block.nodelist.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render
bit = node.render_annotated(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render_annotated
return self.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/loader_tags.py in render
result = block.nodelist.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render
bit = node.render_annotated(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render_annotated
return self.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/defaulttags.py in render
nodelist.append(node.render_annotated(context)) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render_annotated
return self.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/defaulttags.py in render
return nodelist.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render
bit = node.render_annotated(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render_annotated
return self.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render
output = self.filter_expression.resolve(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in resolve
obj = self.var.resolve(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in resolve
value = self._resolve_lookup(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in _resolve_lookup
current = current() ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/wagtail/wagtailadmin/compare.py in htmldiff
BeautifulSoup(force_text(self.val_a), 'html5lib').getText(), ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/utils/encoding.py in force_text
s = six.text_type(s) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/wagtail/wagtailcore/blocks/stream_block.py in __str__
return self.__html__() ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/wagtail/wagtailcore/blocks/stream_block.py in __html__
return self.stream_block.render(self) ...
▶ Local vars
/usr/local/lib/python2.7/site- packages/wagtail/wagtailcore/blocks/base.py in render
return self.render_basic(value, context=context) ...
▶ Local vars
/usr/local/lib/python2.7/site- packages/wagtail/wagtailcore/blocks/stream_block.py in render_basic
for child in value ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/wagtail/wagtailcore/blocks/base.py in render
return self.block.render(self.value, context=context)
您似乎有一个自定义 StreamField 块,它定义了自己的 render
方法。此方法在 Wagtail 1.6 中更新为接受 context
关键字参数,因此您需要按此处所述更新它:
旧签名(没有 context
关键字参数)将继续在 Wagtail 1.6 和 1.7 中工作,但会输出弃用警告;在 Wagtail 1.8 中完全放弃了对它的支持。
StreamField 块现在允许自定义 get_template 方法来覆盖 Wagtail 2.0 实例中的模板。
http://docs.wagtail.io/en/stable/releases/2.0.html#other-features
在 1.9 版本上,尝试在本地比较页面新功能的修订,当:
render() got an unexpected keyword argument 'context'
Request Method: GET
Request URL: http://localhost:8000/admin/pages/48/revisions/compare/488...489/
Django Version: 1.10.5
Exception Type: TypeError
Exception Value:
render() got an unexpected keyword argument 'context'
Exception Location: /usr/local/lib/python2.7/site- packages/wagtail/wagtailcore/blocks/base.py in render, line 442
Python Executable: /usr/local/bin/python2
Python Version: 2.7.13
Python Path:
['/code',
'/usr/local/bin',
'/usr/local/lib/python27.zip',
'/usr/local/lib/python2.7',
'/usr/local/lib/python2.7/plat-linux2',
'/usr/local/lib/python2.7/lib-tk',
'/usr/local/lib/python2.7/lib-old',
'/usr/local/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/site-packages']
Server time: Thu, 23 Feb 2017 14:51:34 +0000
Error during template rendering
In template /usr/local/lib/python2.7/site- packages/wagtail/wagtailadmin/templates/wagtailadmin/pages/revisions/comp are.html, error at line 37
render() got an unexpected keyword argument 'context'
27 </thead>
28
29 <tbody>
30 {% for comp in comparison %}
31 <tr>
32 <td class="title" valign="top">
33 <h2>{{ comp.field_label }}:</h2>
34 </td>
35 <td class="comparison{% if not comp.is_field %} no-padding{% endif %}">
36 {% if comp.is_field %}
37 {{ comp.htmldiff }}
38 {% elif comp.is_child_relation %}
39 {% for child_comp in comp.get_child_comparisons %}
40 <div class="comparison__child-object {% if child_comp.is_addition %}addition{% elif child_comp.is_deletion %}deletion{% endif %}">
41 {% with child_comp.get_position_change as move %}
42 {% if move %}
43 <div class="help- block help-info">
44 <p>
45 {% if move > 0 %}
46 {% blocktrans count counter=move %}
47 Moved down 1 place.
Traceback Switch to copy-and-paste view
/usr/local/lib/python2.7/site-packages/django/core/handlers/exception.py in inner
response = get_response(request) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py in _legacy_get_response
response = self._get_response(request) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py in _get_response
response = self.process_exception_by_middleware(e, request) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs) ...
▶ Local vars
/usr/local/lib/python2.7/site- packages/django/views/decorators/cache.py in _cache_controlled
response = viewfunc(request, *args, **kw) ...
▶ Local vars
/usr/local/lib/python2.7/site- packages/wagtail/wagtailadmin/decorators.py in decorated_view
return view_func(request, *args, **kwargs) ...
▶ Local vars
/usr/local/lib/python2.7/site- packages/wagtail/wagtailadmin/views/pages.py in revisions_compare
'comparison': comparison, ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/shortcuts.py in render
content = loader.render_to_string(template_name, context, request, using=using) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/loader.py in render_to_string
return template.render(context, request) ...
▶ Local vars
/usr/local/lib/python2.7/site- packages/django/template/backends/django.py in render
return self.template.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render
return self._render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in _render
return self.nodelist.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render
bit = node.render_annotated(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render_annotated
return self.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/loader_tags.py in render
return compiled_parent._render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in _render
return self.nodelist.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render
bit = node.render_annotated(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render_annotated
return self.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/loader_tags.py in render
return compiled_parent._render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in _render
return self.nodelist.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render
bit = node.render_annotated(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render_annotated
return self.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/loader_tags.py in render
return compiled_parent._render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in _render
return self.nodelist.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render
bit = node.render_annotated(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render_annotated
return self.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/loader_tags.py in render
result = block.nodelist.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render
bit = node.render_annotated(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render_annotated
return self.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/loader_tags.py in render
result = block.nodelist.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render
bit = node.render_annotated(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render_annotated
return self.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/defaulttags.py in render
nodelist.append(node.render_annotated(context)) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render_annotated
return self.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/defaulttags.py in render
return nodelist.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render
bit = node.render_annotated(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render_annotated
return self.render(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in render
output = self.filter_expression.resolve(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in resolve
obj = self.var.resolve(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in resolve
value = self._resolve_lookup(context) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/template/base.py in _resolve_lookup
current = current() ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/wagtail/wagtailadmin/compare.py in htmldiff
BeautifulSoup(force_text(self.val_a), 'html5lib').getText(), ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/django/utils/encoding.py in force_text
s = six.text_type(s) ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/wagtail/wagtailcore/blocks/stream_block.py in __str__
return self.__html__() ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/wagtail/wagtailcore/blocks/stream_block.py in __html__
return self.stream_block.render(self) ...
▶ Local vars
/usr/local/lib/python2.7/site- packages/wagtail/wagtailcore/blocks/base.py in render
return self.render_basic(value, context=context) ...
▶ Local vars
/usr/local/lib/python2.7/site- packages/wagtail/wagtailcore/blocks/stream_block.py in render_basic
for child in value ...
▶ Local vars
/usr/local/lib/python2.7/site-packages/wagtail/wagtailcore/blocks/base.py in render
return self.block.render(self.value, context=context)
您似乎有一个自定义 StreamField 块,它定义了自己的 render
方法。此方法在 Wagtail 1.6 中更新为接受 context
关键字参数,因此您需要按此处所述更新它:
旧签名(没有 context
关键字参数)将继续在 Wagtail 1.6 和 1.7 中工作,但会输出弃用警告;在 Wagtail 1.8 中完全放弃了对它的支持。
StreamField 块现在允许自定义 get_template 方法来覆盖 Wagtail 2.0 实例中的模板。
http://docs.wagtail.io/en/stable/releases/2.0.html#other-features