djangocms-frontend icon indicating copy to clipboard operation
djangocms-frontend copied to clipboard

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

Open Enkil11 opened this issue 9 months ago • 3 comments

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

Enkil11 avatar Feb 10 '25 16:02 Enkil11

@Enkil11 Which djangocms-frontend version (1.x or 2.0a1)?

fsbraun avatar Feb 10 '25 18:02 fsbraun

@fsbraun I used the version 2.0.0a1

Enkil11 avatar Feb 11 '25 00:02 Enkil11

I will have to look into this. I think this is a compatibility issue - in 2.0 the image mixing did change.

fsbraun avatar Feb 11 '25 06:02 fsbraun

HI @fsbraun , I would love to work on this .

p-r-a-v-i-n avatar Jul 28 '25 14:07 p-r-a-v-i-n

@p-r-a-v-i-n Did you have a chance to look into this?

fsbraun avatar Aug 15 '25 11:08 fsbraun

Hi @fsbraun , I did but I could not able to reproduce the bug.

p-r-a-v-i-n avatar Aug 16 '25 03:08 p-r-a-v-i-n