'Context' object has no attribute 'render_context'

I am running Django==3.2.12 and trying to generate a rendered tewmplate string. The following is the nuts and bolts of it....

I am recieving the error "'Context' object has no attribute 'render_context'" and can not make any sence of it. It used to work fine.

I'm using {% load mjml %} which is installed using node_modules with

MJML_BACKEND_MODE = "cmd"
MJML_EXEC_CMD = "node_modules/.bin/mjml"

    from django.template import Template, Context
    
    template = Template(verbatum)
    context = Context({})

    try:
        html_template = template.render(context)
    except Exception as err:
        html_template = str(err)

Traceback....

    Internal Server Error: /admin/emailing/emailtemplate/1/change/
    Traceback (most recent call last):
      File "/Users/sbrown/.local/share/virtualenvs/mjml-NNm5TF3H/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
        response = get_response(request)
      File "/Users/sbrown/.local/share/virtualenvs/mjml-NNm5TF3H/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
        response = wrapped_callback(request, *callback_args, **callback_kwargs)
      File "/Users/sbrown/.local/share/virtualenvs/mjml-NNm5TF3H/lib/python3.9/site-packages/django/contrib/admin/options.py", line 616, in wrapper
        return self.admin_site.admin_view(view)(*args, **kwargs)
      File "/Users/sbrown/.local/share/virtualenvs/mjml-NNm5TF3H/lib/python3.9/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
        response = view_func(request, *args, **kwargs)
      File "/Users/sbrown/.local/share/virtualenvs/mjml-NNm5TF3H/lib/python3.9/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
        response = view_func(request, *args, **kwargs)
      File "/Users/sbrown/.local/share/virtualenvs/mjml-NNm5TF3H/lib/python3.9/site-packages/django/contrib/admin/sites.py", line 232, in inner
        return view(request, *args, **kwargs)
      File "/Users/sbrown/.local/share/virtualenvs/mjml-NNm5TF3H/lib/python3.9/site-packages/django/contrib/admin/options.py", line 1660, in change_view
        return self.changeform_view(request, object_id, form_url, extra_context)
      File "/Users/sbrown/.local/share/virtualenvs/mjml-NNm5TF3H/lib/python3.9/site-packages/django/utils/decorators.py", line 43, in _wrapper
        return bound_method(*args, **kwargs)
      File "/Users/sbrown/.local/share/virtualenvs/mjml-NNm5TF3H/lib/python3.9/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
        response = view_func(request, *args, **kwargs)
      File "/Users/sbrown/.local/share/virtualenvs/mjml-NNm5TF3H/lib/python3.9/site-packages/django/contrib/admin/options.py", line 1540, in changeform_view
        return self._changeform_view(request, object_id, form_url, extra_context)
      File "/Users/sbrown/.local/share/virtualenvs/mjml-NNm5TF3H/lib/python3.9/site-packages/django/contrib/admin/options.py", line 1586, in _changeform_view
        self.save_model(request, new_object, form, not add)
      File "/Users/sbrown/.local/share/virtualenvs/mjml-NNm5TF3H/lib/python3.9/site-packages/django/contrib/admin/options.py", line 1099, in save_model
        obj.save()
      File "/Applications/MAMP/htdocs/mjml/emailing/models.py", line 42, in save
        self.html_template = template.render(context)
      File "/Users/sbrown/.local/share/virtualenvs/mjml-NNm5TF3H/lib/python3.9/site-packages/django/template/base.py", line 166, in render
        with context.render_context.push_state(self):
    AttributeError: 'Context' object has no attribute 'render_context'
Back to Top