Lean enterprise content management powered by Django.
—
Django CMS provides comprehensive template tag functionality for rendering CMS content in Django templates, including placeholder rendering, page attributes, navigation menus, and powerful inline editing capabilities.
Essential template tags for rendering CMS content with placeholder support and inheritance.
# Template tag usage (in Django templates)
{% placeholder "slot_name" %}
{% placeholder "slot_name" inherit %}
{% placeholder "slot_name" inherit or %}
<div>Fallback content when placeholder is empty</div>
{% endplaceholder %}
{% static_placeholder "identifier" %}
{% static_placeholder "identifier" site %}
{% show_placeholder "identifier" %}
{% show_placeholder_by_id page_lookup "slot_name" %}
{% show_uncached_placeholder "identifier" %}
{% show_uncached_placeholder_by_id page_lookup "slot_name" %}
{% render_placeholder placeholder %}
{% render_placeholder placeholder language width %}
{% render_placeholder placeholder inherit=True %}
{% render_placeholder placeholder as content %}
{% render_uncached_placeholder placeholder_object %}Template tags for generating page URLs and accessing page attributes.
# Page URL generation
{% page_url page_lookup %}
{% page_url page_lookup as url_var %}
{% page_url "page-reverse-id" %}
{% page_url page_object %}
{% page_id_url page_id %}
# Page attributes
{% page_attribute "title" %}
{% page_attribute "slug" %}
{% page_attribute "meta_description" %}
{% page_attribute "page_title" %}
{% page_attribute "menu_title" %}
{% page_attribute "changed_date" %}
{% page_attribute "changed_by" %}
{% page_attribute "title" as page_title %}Template tags for rendering individual plugins and plugin-related functionality.
# Plugin rendering
{% render_plugin plugin_instance %}
{% render_plugin_block plugin_instance %}
<div>Custom content linked to plugin editing</div>
{% endrender_plugin_block %}
{% render_extra_menu_items obj template %}Powerful template tags that enable inline editing by linking content to Django admin changeforms.
# Model editing integration
{% render_model instance attribute %}
{% render_model instance attribute edit_fields %}
{% render_model instance attribute edit_fields language %}
{% render_model instance attribute edit_fields language filters %}
{% render_model instance attribute edit_fields language filters view_url %}
{% render_model instance attribute edit_fields language filters view_url view_method %}
{% render_model instance attribute as varname %}
{% render_model_icon instance %}
{% render_model_add model_class %}
{% render_model_block instance attribute %}
<h1>{{ instance.attribute }}</h1>
{% endrender_model_block %}
{% render_model_add_block model_class %}
<div class="add-button">Add New Item</div>
{% endrender_model_add_block %}Template tags for CMS toolbar integration and admin functionality.
# CMS toolbar and admin integration
{% cms_toolbar %}
{% cms_admin_url "viewname" %}
{% cms_admin_url "viewname" arg1 arg2 %}
{% cms_admin_url "viewname" as admin_url %}{% load cms_tags %}
<!DOCTYPE html>
<html>
<head>
<title>{% page_attribute "page_title" %} | My Site</title>
<meta name="description" content="{% page_attribute "meta_description" %}">
</head>
<body>
{% cms_toolbar %}
<header>
<h1>{% page_attribute "title" %}</h1>
</header>
<main>
{% placeholder "content" %}
</main>
<aside>
{% placeholder "sidebar" inherit or %}
<div class="default-sidebar">
<h3>Default Sidebar Content</h3>
<p>This appears when sidebar is empty.</p>
</div>
{% endplaceholder %}
</aside>
<footer>
{% static_placeholder "footer" %}
</footer>
</body>
</html>{% load cms_tags %}
<!-- Basic placeholder -->
{% placeholder "hero" %}
<!-- Placeholder with inheritance from parent pages -->
{% placeholder "sidebar" inherit %}
<!-- Placeholder with fallback content -->
{% placeholder "banner" or %}
<div class="default-banner">
<h2>Welcome to our site!</h2>
</div>
{% endplaceholder %}
<!-- Render placeholder with size constraints -->
{% render_placeholder page.placeholders.content width=800 %}
<!-- Uncached placeholder for dynamic content -->
{% render_uncached_placeholder dynamic_placeholder %}
<!-- Static placeholder for site-wide content -->
{% static_placeholder "site_notice" %}
<!-- Site-specific static placeholder -->
{% static_placeholder "local_footer" site %}{% load cms_tags menu_tags %}
<!-- Page URL generation -->
<a href="{% page_url "about" %}">About Us</a>
<a href="{% page_url home_page %}">Home</a>
<!-- Store URL in variable -->
{% page_url "contact" as contact_url %}
<a href="{{ contact_url }}">Contact</a>
<!-- Navigation menu -->
{% show_menu 0 100 100 100 %}
<!-- Breadcrumb navigation -->
{% show_breadcrumb 0 "breadcrumb.html" %}
<!-- Submenu -->
{% show_sub_menu 1 %}{% load cms_tags %}
<!-- Make model fields editable -->
<article>
<h1>{% render_model article "title" %}</h1>
<div class="meta">
Published: {% render_model article "pub_date" %}
By: {% render_model article "author" %}
</div>
<div class="content">
{% render_model article "content" %}
</div>
</article>
<!-- Block-level editing -->
{% render_model_block article "title" %}
<h1 class="special-title">{{ article.title }}</h1>
{% endrender_model_block %}
<!-- Add new model instances -->
{% render_model_add Article %}
<!-- Edit icons -->
<div class="admin-tools">
{% render_model_icon article %}
{% render_model_add Article %}
</div>{% load cms_tags menu_tags %}
<nav class="main-navigation">
{% show_menu 0 1 100 100 "menu/main_menu.html" %}
</nav>
<main class="content-area">
<!-- Main content with inheritance -->
{% placeholder "content" inherit %}
<!-- Conditional placeholders -->
{% if page.reverse_id == "homepage" %}
{% placeholder "hero_banner" %}
{% placeholder "features" %}
{% else %}
{% placeholder "page_header" %}
{% endif %}
<!-- Dynamic plugin rendering -->
{% for plugin in page.get_placeholders.content.get_plugins %}
{% render_plugin plugin %}
{% endfor %}
</main>
<aside class="sidebar">
<!-- Static content with fallback -->
{% static_placeholder "sidebar_content" or %}
{% placeholder "page_sidebar" inherit or %}
<div class="default-sidebar">
<h3>Related Pages</h3>
{% show_menu 1 100 0 1 "menu/sidebar_menu.html" %}
</div>
{% endplaceholder %}
{% endstatic_placeholder %}
</aside>{% load cms_tags %}
<!-- CMS toolbar (required for editing) -->
{% cms_toolbar %}
<!-- Admin URLs with language context -->
<div class="admin-links">
<a href="{% cms_admin_url "admin:cms_page_changelist" %}">
Manage Pages
</a>
{% cms_admin_url "admin:cms_page_add" as add_page_url %}
<a href="{{ add_page_url }}">Add Page</a>
</div>
<!-- Conditional admin content -->
{% if request.user.is_staff %}
<div class="admin-panel">
{% render_model current_page "title" %}
{% render_model_add PageContent %}
</div>
{% endif %}# Template context objects (available in templates)
class TemplateContext:
"""
Template context for CMS template tags.
Available variables:
- request: Current HTTP request
- current_page: Active CMS page
- cms_content_renderer: Content rendering engine
- cms_toolbar: CMS toolbar instance (when in preview mode)
"""
class PlaceholderContext:
"""
Context for placeholder rendering.
Variables:
- placeholder: Placeholder instance
- plugins: List of plugins in placeholder
- width: Requested width for responsive plugins
- language: Current language code
"""Install with Tessl CLI
npx tessl i tessl/pypi-django-cms