Skip to content

Upgrading to Django 4.0 gives me "AttributeError: 'SafeString' object has no attribute 'get_bundle'" #319

@pwhipp

Description

@pwhipp

I've upgraded the venv from python 3.9.2/django 3.0.2 to Python 3.10.4/django 4.0.4 - django-webpack-loader is 1.5.0

ERROR 2022-05-29 15:06:12,756 log 186271 140206875318016 Internal Server Error: /
Traceback (most recent call last):
  File "/home/paul/wk/cliosoft/sosmgrweb/venv/lib/python3.10/site-packages/asgiref/sync.py", line 472, in thread_handler
    raise exc_info[1]
  File "/home/paul/wk/cliosoft/sosmgrweb/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 42, in inner
    response = await get_response(request)
  File "/home/paul/wk/cliosoft/sosmgrweb/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 284, in _get_response_async
    response = await sync_to_async(
  File "/home/paul/wk/cliosoft/sosmgrweb/venv/lib/python3.10/site-packages/asgiref/sync.py", line 435, in __call__
    ret = await asyncio.wait_for(future, timeout=None)
  File "/usr/lib/python3.10/asyncio/tasks.py", line 408, in wait_for
    return await fut
  File "/home/paul/wk/cliosoft/sosmgrweb/venv/lib/python3.10/site-packages/asgiref/current_thread_executor.py", line 22, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/paul/wk/cliosoft/sosmgrweb/venv/lib/python3.10/site-packages/asgiref/sync.py", line 476, in thread_handler
    return func(*args, **kwargs)
  File "/home/paul/wk/cliosoft/sosmgrweb/venv/lib/python3.10/site-packages/django/template/response.py", line 114, in render
    self.content = self.rendered_content
  File "/home/paul/wk/cliosoft/sosmgrweb/venv/lib/python3.10/site-packages/django/template/response.py", line 92, in rendered_content
    return template.render(context, self._request)
  File "/home/paul/wk/cliosoft/sosmgrweb/venv/lib/python3.10/site-packages/django/template/backends/django.py", line 62, in render
    return self.template.render(context)
  File "/home/paul/wk/cliosoft/sosmgrweb/venv/lib/python3.10/site-packages/django/template/base.py", line 175, in render
    return self._render(context)
  File "/home/paul/wk/cliosoft/sosmgrweb/venv/lib/python3.10/site-packages/django/template/base.py", line 167, in _render
    return self.nodelist.render(context)
  File "/home/paul/wk/cliosoft/sosmgrweb/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/home/paul/wk/cliosoft/sosmgrweb/venv/lib/python3.10/site-packages/django/template/base.py", line 1000, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "/home/paul/wk/cliosoft/sosmgrweb/venv/lib/python3.10/site-packages/django/template/base.py", line 958, in render_annotated
    return self.render(context)
  File "/home/paul/wk/cliosoft/sosmgrweb/venv/lib/python3.10/site-packages/django/template/library.py", line 239, in render
    output = self.func(*resolved_args, **resolved_kwargs)
  File "/home/paul/wk/cliosoft/sosmgrweb/src/front_end/templatetags/front_end.py", line 16, in render_bundle
    tags = get_as_tags(bundle_name, extension=extension, config=config, attrs=attrs)
  File "/home/paul/wk/cliosoft/sosmgrweb/src/front_end/templatetags/front_end.py", line 21, in get_as_tags
    bundle = _get_bundle(bundle_name, extension, config)
  File "/home/paul/wk/cliosoft/sosmgrweb/venv/lib/python3.10/site-packages/webpack_loader/utils.py", line 39, in _get_bundle
    bundle = loader.get_bundle(bundle_name)
AttributeError: 'SafeString' object has no attribute 'get_bundle'

The template is unchanged:

{% load static core %}
{% load render_bundle from front_end %}
<!DOCTYPE html>
<html lang="en">
<head>
    <title>{{ site_name }}</title>
    <link rel="shortcut icon" type="image/png" href="{% static 'favicon.ico' %}"/>
    <link href="{% static 'bootstrap-3.3.6-dist/css/bootstrap.min.css' %}" rel="stylesheet">
    <link href="{% static 'css/style.css' %}" rel="stylesheet">
    <link href="{% static 'font-awesome-new/css/fontawesome-all.css' %}"  rel="stylesheet">
    <link href="{% static 'font-awesome-new/css/fa-solid.css' %}"  rel="stylesheet">
    <link href="{% static 'font-awesome-new/css/fa-light.css' %}"  rel="stylesheet">
    <link href="{% static 'font-awesome-new/css/fa-regular.css' %}"  rel="stylesheet">
    <link href="{% static 'select2/css/select2.min.css' %}"  rel="stylesheet">
    <link href="{% static 'css/codemirror.css' %}"  rel="stylesheet">
    <link href="{% static 'css/core.css' %}"  rel="stylesheet">
    <link href="{% static 'css/react-select.css' %}"  rel="stylesheet">
    <link href="{% static 'css/sosadmin.css' %}"  rel="stylesheet">
    <link href="{% static 'Roboto-fonts/stylesheet.css' %}"  rel="stylesheet">
    <script>
      window.configuration = {{ configuration|js }};
      window.initial_view_states = {{ initial_view_states|js }};
    </script>
</head>

<body class="sos-body">
<div id="main" ></div>
{% render_bundle 'main' %}
</body>
</html>

I can't find anything online about this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions