Python Wagtail 崩溃 6.3.1“Streamfield 对象没有属性‘bind_to_model’

问题描述 投票:0回答:1

(今天下午 4 点根据下面给出的评论进行编辑。)

将旧的 Wagtail 网站更新到当前版本时,我遇到此错误,位于

admin/panels/group.py
第 74 行:

AttributeError: 'StreamField' object has no attribute 'bind_to_model'

因为这显然是在 WagTail 软件中作为分发的,我很困惑。


完整的回溯如下:

Exception in thread django-main-thread:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/threading.py", line 1041, in _bootstrap_inner
self.run()
~~~~~~~~^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/threading.py", line 992, in run
self._target(*self._args, **self._kwargs)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mike/.virtualenvs/sdenv/lib/python3.13/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
~~^^^^^^^^^^^^^^^^^
File "/Users/mike/.virtualenvs/sdenv/lib/python3.13/site-packages/django/core/management/commands/runserver.py", line 134, in inner_run
self.check(display_num_errors=True)
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mike/.virtualenvs/sdenv/lib/python3.13/site-packages/django/core/management/base.py", line 486, in check
all_issues = checks.run_checks(
app_configs=app_configs,
...<2 lines>...
databases=databases,
)
File "/Users/mike/.virtualenvs/sdenv/lib/python3.13/site-packages/django/core/checks/registry.py", line 88, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/Users/mike/.virtualenvs/sdenv/lib/python3.13/site-packages/wagtail/admin/checks.py", line 69, in get_form_class_check
edit_handler = cls.get_edit_handler()
File "/Users/mike/.virtualenvs/sdenv/lib/python3.13/site-packages/wagtail/utils/decorators.py", line 54, in call
return self.value
^^^^^^^^^^
File "/Users/mike/.virtualenvs/sdenv/lib/python3.13/site-packages/django/utils/functional.py", line 47, in get
res = instance.dict[self.name] = self.func(instance)
~~~~~~~~~^^^^^^^^^^
File "/Users/mike/.virtualenvs/sdenv/lib/python3.13/site-packages/wagtail/utils/decorators.py", line 50, in value
return self.fn(self.cls)
~~~~~~~^^^^^^^^^^
File "/Users/mike/.virtualenvs/sdenv/lib/python3.13/site-packages/wagtail/admin/panels/page_utils.py", line 73, in _get_page_edit_handler
return edit_handler.bind_to_model(cls)
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
File "/Users/mike/.virtualenvs/sdenv/lib/python3.13/site-packages/wagtail/admin/panels/base.py", line 146, in bind_to_model
new.on_model_bound()
~~~~~~~~~~~~~~~~~~^^
File "/Users/mike/.virtualenvs/sdenv/lib/python3.13/site-packages/wagtail/admin/panels/group.py", line 74, in on_model_bound
self.children = [child.bind_to_model(self.model) for child in self.children]
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
File "/Users/mike/.virtualenvs/sdenv/lib/python3.13/site-packages/wagtail/admin/panels/base.py", line 146, in bind_to_model
new.on_model_bound()
~~~~~~~~~~~~~~~~~~^^
File "/Users/mike/.virtualenvs/sdenv/lib/python3.13/site-packages/wagtail/admin/panels/group.py", line 74, in on_model_bound
self.children = [child.bind_to_model(self.model) for child in self.children]
^^^^^^^^^^^^^^^^^^^
AttributeError: 'StreamField' object has no attribute 'bind_to_model'

python wagtail wagtail-streamfield
1个回答
0
投票

该错误表明面板定义中有一个

StreamField
对象,例如
content_panels
。这是无效的 - 它应该只包含面板对象,例如
FieldPanel

作为 Wagtail 2.x 到 6.x 升级过程的一部分,您必须

StreamFieldPanel
的任何实例替换为普通的
FieldPanel
- 我最好的猜测是您在执行此操作时犯了一个错误,并且将
StreamFieldPanel
改为
StreamField

© www.soinside.com 2019 - 2024. All rights reserved.