pythonwagtailwagtail-streamfield

Python Wagtail crashes 6.3.1 "Streamfield object has no attribute 'bind_to_model'


While updating an old Wagtail website to the current version, I encounter this error, in admin/panels/group.py line 74:

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

Since this is apparently in the Wagtail software as distributed, I am quite confused.


The full traceback is as follows:

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'

Solution

  • The error indicates that you have a StreamField object inside a panels definition such as content_panels. This isn't valid - it should only contain panel objects such as FieldPanel.

    As part of the Wagtail 2.x to 6.x upgrade process, you would have to replace any instances of StreamFieldPanel with a plain FieldPanel - my best guess is that you made a mistake while doing this, and changed StreamFieldPanel to StreamField instead.