django-cms this.ui.container.data(...).push is not a function

June 19, 2021, 7:02 a.m.

In django 3.7.X (possibly in an earlier version) until current 3.8.0 (at the time of writing) has an error when opening the page structure:

`Uncaught TypeError: this.ui.container.data(...).push is not a function
at s.initialize (bundle.toolbar.min.js:1)

It occurs when the template has several static_placeholder with the same names, for example: {% static_placeholder 'header' %}.

There is an issue https://github.com/django-cms/django-cms/issues/6889 on Github, and developers have not fixed this case at this moment.

By digging around in the bundle.toolbar.min.js file where the error occurs, I was able to find a workaround.

Workaround

Copy /path_to_env_of_my_project/lib/python3.8/site-packages/cms/static/cms/js/dist/3.8.0/bundle.toolbar.min.js file to /path_to_my_project/static/cms/js/dist/3.8.0/bundle.toolbar.min.js.

Note that instead of the 3.8.0 folder name, use the folder name corresponding to the version of django-cms you are using. If you are using django-cms == 3.7.4, then the path will be like path_to_my_project/static/cms/js/dist/3.7.4/bundle.toolbar.min.js

This file contains minified (compressed) js code, so you can reformat the code in this file for convenience. In PyCharm, this is done in menu Code \ Reformat code (hotkey Ctrl + Alt + L).

Then, before the code where the error occurs (you can find the line, for example, through the Google developer tools and search for the line of code in the file), add if (Array.isArray(this.ui.container.data("cms"))):

...case"plugin":if (Array.isArray(this.ui.container.data("cms"))) this.ui.container.data("cms").push(this.options), xe.aliasPluginDuplicatesMap[this.options.plugin_id] = !0, this._setPlugin(), _e() && this._collapsables();...

Now django-cms will pick up the new file and there should be no more errors.

 

Also keep in mind that I tested this method only on django-cms version 3.8.0, so it's not a fact that it might work with other versions.

You can also download my corrected bundle.toolbar.min.js for django-cms == 3.8.0:

bundle.toolbar.min.js (668.2 KB)

Rate this article

0 from 5 (total 0 ratings)

You can send feedback, suggestions or comments on this article using this form:

Fields marked by star ( * ) is required.

Thank you for yor feedback!

After clicking the "Send" button, your message will be delivered to me on the mail.

Author of Article

Artem Maltsev

Web-developer, having the knowlenge of programming language - Python, framework - Django, content management system - Django CMS, platform of e-commerce site - Django Shop and many other applications, using this technologies.

The right to use content on this page https://vivazzi.pro/it/django-cms-uicontainerdatapush-not-function/:

Permission is granted to copy an content with its author and reference to the original without using the parameter rel="nofollow" in tag <a>. Usage:

Author of Article: Artem Maltsev
Link to article: <a href="https://vivazzi.pro/it/django-cms-uicontainerdatapush-not-function/">https://vivazzi.pro/it/django-cms-uicontainerdatapush-not-function/</a>

More: Terms of site usage

Comments: 0

You can leave a comment as an unregistered user.

But if you sing up, you can:

  • receive notifications
  • view your comments
  • be able to use all the functions of the developed services

To comment in one's own name you should log in or sign up on Vuspace website

Send

There is no search on this site, so I offer to use usual search engine, for example, Google, adding "vivazzi" after your request.

Try it

Select currency for displaying monetary values