jazzband / wagtailmenus

An app to help you manage and render menus in your Wagtail projects more effectively
MIT License
398 stars 138 forks source link

Wagtail 3.0 error? `TabbedInterface.bind_to_model(model) must be called before get_bound_panel` #421

Closed janbaykara closed 2 years ago

janbaykara commented 2 years ago

When opening a main menu / flat menu edit page, an uncaught error.

Environment

Runing python 3.9, Django 4, Wagtail 3.0

Frontend report

<h1>ImproperlyConfigured
       at /admin/wagtailmenus/flatmenu/edit/3/</h1>
<pre class="exception_value">TabbedInterface.bind_to_model(model) must be called before get_bound_panel</pre>

Request Method: | GET
-- | --
http://localhost:8000/admin/wagtailmenus/flatmenu/edit/3/
4.0.4
ImproperlyConfigured
TabbedInterface.bind_to_model(model) must be called before get_bound_panel
/home/vscode/.cache/pypoetry/virtualenvs/app-xS3fZVNL-py3.9/lib/python3.9/site-packages/wagtail/admin/panels.py, line 235, in get_bound_panel
/home/vscode/.cache/pypoetry/virtualenvs/app-xS3fZVNL-py3.9/bin/python

Full stack trace

Traceback (most recent call last):
File "D:\Users\ani\Documents\venv\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
response = get_response(request)
File "D:\Users\ani\Documents\venv\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "D:\Users\ani\Documents\venv\lib\site-packages\django\views\decorators\cache.py", line 44, in wrapped_view_func
response = view_func(request, *args, **kwargs)
File "D:\Users\ani\Documents\venv\lib\site-packages\wagtail\admin\urls_init.py", line 161, in wrapper
return view_func(request, *args, **kwargs)
File "D:\Users\ani\Documents\venv\lib\site-packages\wagtail\admin\auth.py", line 182, in decorated_view
response = view_func(request, *args, **kwargs)
File "D:\Users\ani\Documents\venv\lib\site-packages\wagtail\contrib\modeladmin\options.py", line 445, in edit_view
return view_class.as_view(**kwargs)(request)
File "D:\Users\ani\Documents\venv\lib\site-packages\django\views\generic\base.py", line 64, in view
self.setup(request, *args, **kwargs)
File "D:\Users\ani\Documents\venv\lib\site-packages\wagtail\contrib\modeladmin\views.py", line 161, in setup
self.edit_handler = self.get_edit_handler()
File "D:\Users\ani\Documents\venv\lib\site-packages\wagtailmenus\views.py", line 59, in get_edit_handler
return edit_handler.bind_to(model=self.model)
File "D:\Users\ani\Documents\venv\lib\site-packages\wagtail\admin\panels.py", line 227, in bind_to
return self.get_bound_panel(instance=instance, request=request, form=form)
File "D:\Users\ani\Documents\venv\lib\site-packages\wagtail\admin\panels.py", line 237, in get_bound_panel
% type(self).name

Exception Type: ImproperlyConfigured at /gavekal-wagtail-admin/wagtailmenus/mainmenu/edit/2/
Exception Value: TabbedInterface.bind_to_model(model) must be called before get_bound_panel

Relevant code snippets

https://github.com/jazzband/wagtailmenus/blob/8be2790c01688dd3c9ef7298bdebe94575c0a76a/wagtailmenus/views.py#L50-L60

aliceni81 commented 2 years ago

Here is the traceback:

Traceback (most recent call last): File "D:\Users\ani\Documents\venv\lib\site-packages\django\core\handlers\exception.py", line 47, in inner response = get_response(request) File "D:\Users\ani\Documents\venv\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, callback_kwargs) File "D:\Users\ani\Documents\venv\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func response = view_func(request, *args, *kwargs) File "D:\Users\ani\Documents\venv\lib\site-packages\wagtail\admin\urls__init__.py", line 161, in wrapper return view_func(request, args, kwargs) File "D:\Users\ani\Documents\venv\lib\site-packages\wagtail\admin\auth.py", line 182, in decorated_view response = view_func(request, args, kwargs) File "D:\Users\ani\Documents\venv\lib\site-packages\wagtail\contrib\modeladmin\options.py", line 445, in edit_view return view_class.as_view(kwargs)(request) File "D:\Users\ani\Documents\venv\lib\site-packages\django\views\generic\base.py", line 64, in view self.setup(request, args, **kwargs) File "D:\Users\ani\Documents\venv\lib\site-packages\wagtail\contrib\modeladmin\views.py", line 161, in setup self.edit_handler = self.get_edit_handler() File "D:\Users\ani\Documents\venv\lib\site-packages\wagtailmenus\views.py", line 59, in get_edit_handler return edit_handler.bind_to(model=self.model) File "D:\Users\ani\Documents\venv\lib\site-packages\wagtail\admin\panels.py", line 227, in bind_to return self.get_bound_panel(instance=instance, request=request, form=form) File "D:\Users\ani\Documents\venv\lib\site-packages\wagtail\admin\panels.py", line 237, in get_bound_panel % type(self).name

Exception Type: ImproperlyConfigured at /gavekal-wagtail-admin/wagtailmenus/mainmenu/edit/2/ Exception Value: TabbedInterface.bind_to_model(model) must be called before get_bound_panel

MrCordeiro commented 2 years ago

Hi, wagtailmenus is still not compatible with Wagtail 3.0 unfortunately.

basitiyidir commented 2 years ago

I want to start a new project with Wagtail 3. When will this bug be fixed.

how can i fix it temporarily

Thank you.

janbaykara commented 2 years ago

Can someone who's familiar with Wagtail's panel system comment here with roughly what the problem seems to be? I poked around the code for 5 minutes but it didn't occur. Happy to put up a fix but I can't invest the debugging time right now.

amajai commented 2 years ago

I poked around with the code https://github.com/jazzband/wagtailmenus/blob/8be2790c01688dd3c9ef7298bdebe94575c0a76a/wagtailmenus/views.py#L50-L60 and I noticed that removing this condition stopped the error from showing.

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

Main menu was working fine but a temporary fix for wagtail 3.0.

janbaykara commented 2 years ago

@amajai nice sleuthing. Do you want to submit this as a PR to close this issue? While we're waiting for the maintainers to merge it in, we can point our package managers to your fork.

basitiyidir commented 2 years ago

@amajai nice sleuthing. Do you want to submit this as a PR to close this issue?

I'm waiting for someone to PR.

amajai commented 2 years ago

Alright, I'll make a PR.

janbaykara commented 2 years ago

Some of my end users are blocked by this issue, so I've gone ahead and posted a PR based on @amajai's suggestions here: https://github.com/jazzband/wagtailmenus/pull/422 It seems to work just enough for my purposes, for now, but it'd be good iron out any creases.

Happy to take the PR down if you want to post your PR @amajai.

amajai commented 2 years ago

@janbaykara I was actually going to post PR later today. Had to go over the code and documentation to make proper changes during my free time. Sorry that it took long.

amajai commented 2 years ago

Temporary fix to wagtail 3.0 for now until wagtailmenus gets updated: pip install -e git+https://github.com/amajai/wagtailmenus.git@resolve-wagtailmenus-compatibility-issue-wagtail-3.0#egg=wagtail

basitiyidir commented 2 years ago

Temporary fix to wagtail 3.0 for now until wagtailmenus gets updated: pip install -e git+https://github.com/amajai/wagtailmenus.git@resolve-wagtailmenus-compatibility-issue-wagtail-3.0#egg=wagtail

Thank you. But the following error...

pip._vendor.resolvelib.resolvers.InconsistentCandidate: Provided candidate LinkCandidate('https://files.pythonhosted.org/packages/cf/82/d16a3836856383d2f34686226b927cf076f01da4be49654717c923279d6e/wagtail-3.0-py3-none-any.whl#sha256=4a844d2d1cf5cbc9c48344c6ae9cc5c9f0d1134cd45cd2c484afdedc1164043a (from https://pypi.org/simple/wagtail/) (requires-python:>=3.7)') does not satisfy SpecifierRequirement('wagtail==3.0'), UnsatisfiableRequirement('wagtail')

amajai commented 2 years ago

@basitiyidir Try updating your python version to 3.7 or above.

basitiyidir commented 2 years ago

@basitiyidir Try updating your python version to 3.7 or above.

I am using docker and the python version is python:3.10.2.

Dockerfile

FROM python:3.10.2-slim ...

MrCordeiro commented 2 years ago

Closed by #424

Thanks everyone for your help! ✌️

Please be aware that release to PyPi is still being blocked by #419 and #409. In the meanwhile, you can get the latest version on GitHub directly.