You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

DjangoCMS模板占位符未在结构视图显示问题排查求助

Troubleshooting Django CMS Placeholders Not Showing in Structure View

Hey there, let's work through why your Django CMS placeholders aren't appearing in the structure view. I've debugged this exact issue plenty of times, so here are the key checks to run through:

  • Verify placeholder tags are properly added to your templates
    Make sure you've defined placeholders using the correct template tags in your base or child templates. For regular placeholders, use {% placeholder "your_placeholder_name" %}; for static placeholders, use {% static_placeholder "static_placeholder_name" %}. Double-check that the placeholder name matches what you expect to see in the structure view.

  • Confirm your CMS_TEMPLATES setting is correct
    Head to settings.py and ensure your CMS_TEMPLATES list is formatted properly. Each entry should be a tuple with the template path and a human-readable name, like this:

    CMS_TEMPLATES = [
        ('base.html', 'Base Template'),
        ('pages/home.html', 'Home Page Template'),
    ]
    

    Also, when creating or editing a page in the CMS admin, make sure you've selected the template that actually contains your placeholders—it's easy to accidentally pick the wrong one!

  • Check template inheritance setup
    If you're using child templates that extend base.html, confirm:

    • The {% extends "base.html" %} tag is the very first line in your child template (no leading HTML, spaces, or comments before it).
    • You aren't accidentally overriding the section of base.html where your placeholders live in the child template.
    • Child templates include their own {% load cms_tags sekizai_tags %} tags (though inheriting from base should handle this, it never hurts to double-check).
  • Ensure Sekizai blocks are present
    Django CMS relies on Sekizai to load critical frontend resources for the structure view. In base.html, make sure you have these blocks in the right places:

    <!-- In the <head> section -->
    {% render_block "css" %}
    
    <!-- Right before closing </body> tag -->
    {% render_block "js" %}
    

    Missing these blocks can break the CMS's admin UI, including placeholder rendering.

  • Clear caches
    Caching is a frequent culprit here. Try:

    • Running python manage.py clearcache to clear Django's server-side cache.
    • Doing a hard refresh of your browser (Ctrl+Shift+R on Windows/Linux, Cmd+Shift+R on Mac) to bypass client-side cache.
    • Logging out and back into the CMS admin after clearing caches.
  • Check user permissions
    Make sure the admin user you're logged in with has the necessary permissions to edit page structure. Specifically, verify they have the cms.change_page permission and access to the placeholder-related permissions (like cms.edit_placeholder).

  • Validate template loading
    Confirm Django is actually loading your templates correctly. Add a piece of test text (like <!-- TEST TEMPLATE LOADED -->) to your base or child template, then visit the frontend page to see if it appears. If not, check your TEMPLATES setting in settings.py to ensure your template directory is included in DIRS or that APP_DIRS is set correctly for apps containing templates.

If none of these fixes work, try temporarily disabling any custom Django CMS plugins or third-party apps to rule out conflicts.

内容的提问来源于stack exchange,提问作者Dennis Gathagu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 10:38:20