wagtail3.0 解决wagtailmenus TabbedInterface.bind_to_model(model) must be called before get_bound_panel

Published on Aug. 22, 2023, 12:11 p.m.

使用wagtailmenus出现如下错误,应该是wagtail3.0和wagtailmenus之间不兼容

File "/home/terry/anaconda3/envs/TkitCMS/lib/python3.10/site-packages/wagtailmenus/views.py", line 59, in get_edit_handler
    return edit_handler.bind_to(model=self.model)
  File "/home/terry/anaconda3/envs/TkitCMS/lib/python3.10/site-packages/wagtail/admin/panels.py", line 227, in bind_to
    return self.get_bound_panel(instance=instance, request=request, form=form)
  File "/home/terry/anaconda3/envs/TkitCMS/lib/python3.10/site-packages/wagtail/admin/panels.py", line 235, in get_bound_panel
    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: TabbedInterface.bind_to_model(model) must be called before get_bound_panel

删除此条件会阻止错误显示。


        if hasattr(edit_handler, 'bind_to'):
            # For Wagtail>=2.5
            return edit_handler.bind_to(model=self.model)

修改后的

https://github.com/napoler/wagtailmenus

可用直接安装

pip install git+https://github.com/napoler/wagtailmenus