Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


render_model templatetag should create unique classnames #2822

stefanfoulis opened this Issue · 4 comments

4 participants

Stefan Foulis Angelo Dini Iacopo Spalletti Patrick Lauber
Stefan Foulis

The {% render_model post "myfield" "myfield" "" safe %} templatetag generates a class on the wrapping div that is used in JS (<div class="cms_plugin cms_plugin-myapp-mymodel-myfield-2 cms_render_model"><p>asdfadsf</p></div>).

If the same model is used multiple times on the same page (e.g a list of blog posts and another list of the same blog post in a "latest posts" plugin in the sidebar). The same class (cms_plugin-myapp-mymodel-myfield-2) is used twice on the same page.

The current effect is that the window openen on doubleclick is not positioned correctly. But it might have other issues as well.

blog-post-placeholder-edit-window wrong-position

Patrick Lauber digi604 added this to the 3.0 milestone
Patrick Lauber digi604 added the blocker label
Angelo Dini

@yakky maybe you might have a quick solution?

Iacopo Spalletti

Quick and dirty solution, which will require to rework tests a bit, is to add a randomization here and in the cms-plugin-whatever DOM class.
The class name is built to be unique per instance but totally deterministic.
Or, we can add a mode parameter to the render_model templatetag and use it in the DOM class name; in this case, it's up to the user to pass the correct mode for every use; something like:

{% render_model post 'abstract' '' '' '' 'main' %}


{% render_model post 'abstract' '' '' '' 'plugin' %}
Patrick Lauber

but isn't this just some JS problem?

Iacopo Spalletti

There are two failing assumptions in this bug:

  1. Every frontend-enabled DOM element shalt be unique per page
  2. Every frontend-enabled model instance shalt be unique per page

I don't know if @FinalAngel can overcome the first one in the javascript, I can try to patch the second one in the plugin.html template

Angelo Dini FinalAngel referenced this issue from a commit in FinalAngel/django-cms
Angelo Dini FinalAngel fixes issue #2822 208afee
Patrick Lauber digi604 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.