django Wagtail 4升级:“BlockWidget”对象没有属性“_block_json”

hc8w905p  于 2023-10-21  发布在  Go
关注(0)|答案(1)|浏览(80)

在阅读并更新Wagtail changelog中所述的可能的破坏性更改后,我在查看任何页面的任何编辑菜单时都会出现以下错误:

'BlockWidget' object has no attribute '_block_json'
Request Method: GET
Request URL:    https://example.com/admin/pages/530/edit/
Django Version: 3.2.9
Exception Type: AttributeError
Exception Value:    
'BlockWidget' object has no attribute '_block_json'
Exception Location: /home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/wagtail/blocks/base.py, line 526, in block_json
Python Executable:  /home/user/.virtualenvs_dev/mysite/bin/python3.10
Python Version: 3.10.9
Python Path:    
['/home/user/projects/mysite/django',
 '/home/user/.virtualenvs_dev/mysite/bin',
 '/usr/local/lib/python310.zip',
 '/usr/local/lib/python3.10',
 '/usr/local/lib/python3.10/lib-dynload',
 '/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages',
 '/home/user/projects/mysite/django/mysite']
Server time:    Tue, 17 Oct 2023 11:02:12 -0500
Error during template rendering

In template /home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/wagtail/admin/templates/wagtailadmin/panels/object_list.html, error at line 9
'BlockWidget' object has no attribute '_block_json'
1   {% load wagtailadmin_tags %}
2   
3   <div class="w-form-width">
4       {% if self.help_text %}
5           {% help_block status="info" %}{{ self.help_text }}{% endhelp_block %}
6       {% endif %}
7       {% for child, identifier in self.visible_children_with_identifiers %}
8           {% panel id_prefix=self.prefix id=identifier classname=child.classes|join:' ' heading=child.heading heading_size="label" icon=child.icon id_for_label=child.id_for_label is_required=child.is_required %}
9               {% component child %}
10          {% endpanel %}
11      {% endfor %}
12  </div>
13

完整的堆栈跟踪如下:

Environment:

Request Method: GET
Request URL: https://example.com/admin/pages/530/edit/

Django Version: 3.2.9
Python Version: 3.10.9
Installed Applications:
['six',
 'formtools',
 'django_otp',
 'django_otp.plugins.otp_static',
 'django_otp.plugins.otp_totp',
 'two_factor',
 'apps.content_blocks',
 'apps.pages.home',
 'apps.pages.utility',
 'apps.pages.search',
 'apps.pages.blank_slate',
 'apps.rates',
 'apps.utils',
 'apps.pages.puput',
 'wagtail.contrib.sitemaps',
 'wagtail.contrib.routable_page',
 'apps.wagtailstreamforms',
 'crispy_forms',
 'apps.wagtail_admin_extension',
 'wagtail.contrib.forms',
 'wagtail.contrib.redirects',
 'wagtail.embeds',
 'wagtail.sites',
 'wagtail.users',
 'wagtail.snippets',
 'wagtail.documents',
 'wagtail.images',
 'wagtail.contrib.search_promotions',
 'wagtail.search',
 'wagtail.admin',
 'wagtail',
 'apps.pages.group_testimonials',
 'apps.pages.emergency_notifications',
 'apps.pages.promotions_carousel',
 'apps.pages.locations',
 'wagtail.contrib.modeladmin',
 'wagtailmenus',
 'wagtail.contrib.table_block',
 'wagtail.contrib.styleguide',
 'modelcluster',
 'taggit',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'user_sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'sekizai',
 'django.contrib.sites',
 'django.contrib.sitemaps',
 'rest_framework',
 'wagtailmetadata',
 'wagtail.api.v2',
 'tinymce',
 'wagtail.contrib.frontend_cache',
 'gunicorn']
Installed Middleware:
['user_sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django_otp.middleware.OTPMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'wagtail.contrib.redirects.middleware.RedirectMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'whitenoise.middleware.WhiteNoiseMiddleware',
 'x_forwarded_for.middleware.XForwardedForMiddleware']

Template error:
In template /home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/wagtail/admin/templates/wagtailadmin/panels/object_list.html, error at line 9
   'BlockWidget' object has no attribute '_block_json'
   1 : {% load wagtailadmin_tags %}
   2 : 
   3 : <div class="w-form-width">
   4 :     {% if self.help_text %}
   5 :         {% help_block status="info" %}{{ self.help_text }}{% endhelp_block %}
   6 :     {% endif %}
   7 :     {% for child, identifier in self.visible_children_with_identifiers %}
   8 :         {% panel id_prefix=self.prefix id=identifier classname=child.classes|join:' ' heading=child.heading heading_size="label" icon=child.icon id_for_label=child.id_for_label is_required=child.is_required %}
   9 :              {% component child %} 
   10 :         {% endpanel %}
   11 :     {% endfor %}
   12 : </div>
   13 : 

Traceback (most recent call last):
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/core/handlers/base.py", line 204, in _get_response
    response = response.render()
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/wagtail/admin/auth.py", line 197, in overridden_render
    return render()
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/response.py", line 105, in render
    self.content = self.rendered_content
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/response.py", line 83, in rendered_content
    return template.render(context, self._request)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 170, in render
    return self._render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/test/utils.py", line 100, in instrumented_test_render
    return self.nodelist.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/test/utils.py", line 100, in instrumented_test_render
    return self.nodelist.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/test/utils.py", line 100, in instrumented_test_render
    return self.nodelist.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/test/utils.py", line 100, in instrumented_test_render
    return self.nodelist.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/test/utils.py", line 100, in instrumented_test_render
    return self.nodelist.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 988, in render
    output = self.filter_expression.resolve(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 671, in resolve
    obj = self.var.resolve(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 796, in resolve
    value = self._resolve_lookup(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 858, in _resolve_lookup
    current = current()
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/wagtail/admin/panels.py", line 405, in render_form_content
    return mark_safe(self.render_html() + self.render_missing_fields())
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/wagtail/admin/ui/components.py", line 20, in render_html
    return template.render(context_data)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 170, in render
    return self._render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/test/utils.py", line 100, in instrumented_test_render
    return self.nodelist.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/defaulttags.py", line 211, in render
    nodelist.append(node.render_annotated(context))
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/defaulttags.py", line 312, in render
    return nodelist.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 988, in render
    output = self.filter_expression.resolve(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 671, in resolve
    obj = self.var.resolve(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 796, in resolve
    value = self._resolve_lookup(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 858, in _resolve_lookup
    current = current()
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/wagtail/admin/ui/components.py", line 20, in render_html
    return template.render(context_data)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 170, in render
    return self._render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/test/utils.py", line 100, in instrumented_test_render
    return self.nodelist.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/defaulttags.py", line 211, in render
    nodelist.append(node.render_annotated(context))
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/wagtail/admin/templatetags/wagtailadmin_tags.py", line 995, in render
    children = self.nodelist.render(context) if self.nodelist else ""
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/template/library.py", line 192, in render
    output = self.func(*resolved_args, **resolved_kwargs)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/wagtail/admin/templatetags/wagtailadmin_tags.py", line 923, in component
    return obj.render_html(context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/wagtail/admin/ui/components.py", line 15, in render_html
    context_data = self.get_context_data(parent_context)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/wagtail/admin/panels.py", line 842, in get_context_data
    rendered_field = self.bound_field.as_widget(attrs=widget_attrs)
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/django/forms/boundfield.py", line 93, in as_widget
    return widget.render(
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/wagtail/blocks/base.py", line 554, in render
    return self.render_with_errors(
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/wagtail/blocks/base.py", line 548, in render_with_errors
    block_json=self.block_json,
  File "/home/user/.virtualenvs_dev/mysite/lib/python3.10/site-packages/wagtail/blocks/base.py", line 525, in block_json
    return self._block_json

Exception Type: AttributeError at /admin/pages/530/edit/
Exception Value: 'BlockWidget' object has no attribute '_block_json'

我使用python poetry来尝试兼容所有的库。它建立得很好,网站运行。正是这个特定的部分,该网站已与实际的Wagtail包,不断失败。你知道可能出了什么问题吗?
我使用的库/版本是:

Babel="2.9.1"
backcall="0.2.0"
bcrypt="3.2.0"
beautifulsoup4="4.9.3"
bleach="4.1.0"
boto3="1.19.11"
botocore="1.22.11"
certifi="2019.11.28"
cffi="1.15.1"
chardet="4.0.0"
click="8.0.3"
cryptography="3.3.2"
decorator="4.4.2"
Django="3.2.9"
django-appconf="1.0.5"
django-bakery="0.12.7"
django-classy-tags="2.0.0"
django-compressor="2.4.1"
django-crispy-forms="1.13.0"
django-debug-toolbar="3.2.2"
django-el-pagination="3.3.0"
django-environ="0.8.1"
django-extensions="3.1.3"
django-filter="2.4.0"                                                              
django-formtools="2.2"
django-model-utils="4.2.0"
django-modelcluster="6.1"
django-multi-email-field="0.6.2"
django-otp="1.1.1"
django-phonenumber-field="5.2.0"
django-recaptcha="2.0.6"
django-redis="5.0.0"
django-redis-cache="3.0.0"
django-sekizai="2.0.0"
django-taggit="3.1.0"
django-tinymce4-lite="1.8.0"
django-treebeard="4.5.1"
django-two-factor-auth="1.13.1"
django-user-sessions="1.7.1"
django-xforwardedfor-middleware="2.0"
djangorestframework="3.12.4"
docutils="0.17.1"
draftjs-exporter="2.1.7"
ecdsa="0.17.0"
elasticsearch="7.15.1"
entrypoints="0.3"
Fabric3="1.14.post1"
fastnumbers="3.2.1"
gevent="21.8.0"
greenlet="1.1.2"
gunicorn="20.1.0"
html5lib="1.1"
idna="3.3"
imagesize="1.3.0"
ipdb="0.13.9"
ipykernel="5.5.6"
ipyparallel="6.3.0"
ipython="7.17.0"
ipython-genutils="0.2.0"
ipywidgets="7.6.5"
jedi="0.18.0"
Jinja2="3.0.2"
jmespath="0.10.0"
jsmin="3.0.0"
jsonschema="3.2.0"
jupyter-client="7.0.6"
jupyter-core="4.9.1"
l18n="2020.6.1"
Markdown="2.6.11"
MarkupSafe="2.0.1"
mistune="0.8.4"
mock="4.0.3"
nbconvert="6.0.7"
nbformat="5.1.3"
nose="1.3.7"
notebook="6.4.5"
olefile="0.46"
pandocfilters="1.5.0"
paramiko="2.8.0"
parso="0.8.2"
pbr="5.7.0"
pexpect="4.8.0"
phonenumberslite="8.12.36"
pickleshare="0.7.5"
Pillow="8.4.0"
prompt-toolkit="3.0.22"
psycopg2="2.8.6"
ptyprocess="0.7.0"
pyasn1="0.4.8"
pycparser="2.20"
pycrypto="2.6.1"
Pygments="2.10.0"
PyNaCl="1.4.0"
python-dateutil="2.8.2"
python-dotenv="0.19.1"
pytz="2023.3"
PyYAML="6.0"
pyzmq="22.3.0"
qrcode="6.1"
qtconsole="5.1.1"
rcssmin="1.0.6"
redis="3.5.3"
requests="2.26.0"
rjsmin="1.1.0"
s3transfer="0.5.0"
simplegeneric="0.8.1"
six="1.16.0"
snowballstemmer="2.1.0"
Sphinx="4.2.0"
sphinxcontrib-websupport="1.2.4"
sqlparse="0.4.2"
terminado="0.12.1"
testpath="0.5.0"
tornado="6.1"
traitlets="4.3.3"
Unidecode="1.3.2"
urllib3="1.26.7"
virtualenv="15.1.0"
wagtail="4.1"
wagtail-metadata="4.0.2"
wagtailmenus="3.1.9"
wcwidth="0.2.5"
webencodings="0.5.1"
whitenoise="5.3.0"
widgetsnbextension="3.5.2"
Willow="1.4"
xggvc2p6

xggvc2p61#

此错误似乎与wagtailstreamforms中报告的错误相匹配:https://github.com/labd/wagtailstreamforms/issues/200
您的包中没有列出wagtailstreamforms,但它列在Wagtailed_APPS中,因此可以推测它包含在项目的代码库中。这需要升级到3.22或更高版本。

相关问题