Skip to content

Commit f819e82

Browse files
committed
fix: inline editing disabled for plugin template tags
1 parent 6d8dc1c commit f819e82

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

djangocms_frontend/templatetags/frontend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,9 @@ class InlineField(CMSEditableObject):
268268
)
269269

270270
def render_tag(self, context, **kwargs):
271-
if context["request"].session.get("inline_editing", True) and isinstance(kwargs["instance"], CMSPlugin):
271+
if context["request"].session.get("inline_editing", True) and isinstance(kwargs["instance"], CMSPlugin) and kwargs["instance"].pk:
272272
# Only allow inline field to be rendered if inline editing is active and the instance is a CMSPlugin
273-
# DummyPlugins of the ``plugin`` tag are cannot be edited
273+
# DummyPlugins of the ``plugin`` tag are cannot be edited (they have no pk in their model class)
274274
kwargs["edit_fields"] = kwargs["attribute"]
275275
return super().render_tag(context, **kwargs)
276276
else:

docs/source/how-to/use-frontend-as-component.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,32 @@ use the ``{% plugin %}`` template tag with each plugin.
9898
Currently, ``{% placeholder %}`` template tags are not supported inside
9999
a ``{% plugin %}`` tag. This is because the ``{% plugin %}`` tag does
100100
preprocess the content and placeholders are not recognized by django CMS.
101+
102+
Multi-line tags
103+
===============
104+
105+
Multi-line tags are not supported in Django templates. For components with many
106+
parameters this can lead to long lines of code. To make the code more readable
107+
you can use the following patch (to be executed, for example during your project's
108+
``AppConfig.ready()`` method):
109+
110+
.. code-block:: python
111+
112+
import re
113+
from django.template import base
114+
115+
base.tag_re = re.compile(base.tag_re.pattern, re.DOTALL)
116+
117+
This will patch the Django template engine **for all templates rendered by it
118+
within your project.** It will however allow templates like this:
119+
120+
.. code-block:: django
121+
122+
{% plugin "card"
123+
card_alignment="center"
124+
card_outline="info"
125+
card_text_color="primary"
126+
card_full_height=True %}
127+
...
128+
{% endplugin %}
129+

0 commit comments

Comments
 (0)