Skip to content

Problem following the "How to extend existing plugins" from the doc #255

Open
@Enkil11

Description

@Enkil11

Describe the bug
I've implemented the GridContainerRenderMixin from the documentation to add a background image and blur effect to a container. Everything works fine as long as I set a background image.

Problem:

If I remove the background image from a container that previously had one, the plugin refuses to render and throws the following error:

Exception when executing plugin.render in GridContainerPlugin (id=113)
TypeError: 'NoneType' object is not subscriptable

This issue persists until I add back a background image or until the server is restarted.
If I create multiple container plugins, some with a background and some without, the ones without a background will consistently trigger the same error.

To Reproduce
Steps to reproduce the behavior:
Steps to reproduce the behavior:

  1. Create a GridContainerPlugin and assign a background image.
  2. Remove the background image and save the container.
  3. The plugin fails to render and throws an error.

OR

  1. Create 2 GridContainerPlugin
  2. Assign a background image to one of them.
  3. The plugin that do not have a background fails to render and throws an error.

Expected behavior
The GridContainerPlugin should be able to render when the background_image is deleted.
The GridContainerPlugin should be able to render with or without a background_image in any case.

Screenshots

Image

Desktop (please complete the following information):

  • Windows
  • Chrome
  • Version 132.0.6834.160

Additional context
Terminal log :
GridContainer.render for plugin pk=113 raised an exception
Traceback (most recent call last):
File "/home/enkil/Luciole/luciole_env/lib/python3.12/site-packages/cms/plugin_rendering.py", line 474, in render_plugin
context = plugin.render(context, instance, placeholder.slot)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/enkil/Luciole/Luciole/theme/frameworks/bootstrap5.py", line 31, in render
print(instance.container_image)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/enkil/Luciole/luciole_env/lib/python3.12/site-packages/djangocms_frontend/helpers.py", line 41, in get
obj = get_related_object(instance.config, self.key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/enkil/Luciole/luciole_env/lib/python3.12/site-packages/djangocms_frontend/helpers.py", line 27, in get_related_object
Model = apps.get_model(scope[field_name]["model"])
~~~~~~~~~~~~~~~~~^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions