How to work with templates#

Application can reuse cms templates by mixing cms template tags and normal django templating language.


New in version 4.0.


Using static_alias requires the installation of djangocms-alias to work.

Plain placeholder cannot be used in templates used by external applications, use static_alias instead.


CMS_TEMPLATE is a context variable available in the context; it contains the template path for CMS pages and application using apphooks, and the default template (i.e.: the first template in CMS_TEMPLATES) for non-CMS managed URLs.

This is mostly useful to use it in the extends template tag in the application templates to get the current page template.

Example: cms template

{% load cms_tags %}
    {% cms_toolbar %}
    {% block main %}
    {% placeholder "main" %}
    {% endblock main %}

Example: application template

{% extends CMS_TEMPLATE %}
{% load cms_tags %}
{% block main %}
{% for item in object_list %}
    {{ item }}
{% endfor %}
{% static_placeholder "sidebar" %}
{% endblock main %}

CMS_TEMPLATE memorises the path of the cms template so the application template can dynamically import it.


render_model allows to edit the django models from the frontend by reusing the django CMS frontend editor.