【问题标题】:how do i get django cms editor to work inside djangos default tags我如何让 django cms 编辑器在 djangos 默认标签中工作
【发布时间】:2021-04-15 03:20:30
【问题描述】:

我正在构建一个 django 应用程序,它允许用户创建 html 内容(用作电子邮件模板),但不断收到 TemplateSyntaxError。

我正在尝试在我自己的视图中使用 django-cms 插件并模板化任何想法。


{% extends 'admin/merchant/base.html' %}
{% load cache %}
{% load cms_tags %}
    
{% block extra_head %}
    {% placeholder "css" %}
{% endblock extra_head %}

{% block content %}
    <body>
        {% cms_toolbar %}

        {% placeholder "content" or %} Nothing is coming through... {% endplaceholder %}
    </body>
{% endblock content %}


但我收到此错误:

Template error:
In template /home/joel/Projects/Vendora Deploy/src/templates/admin/merchant/newsletter/create-page.html, error at line 15
   Invalid block tag on line 15: 'endblock'. Did you forget to register or load this tag?
   5 : {% block extra_head %}
   6 :     {% placeholder "css" %}
   7 : {% endblock extra_head %}
   8 : 
   9 : {% block content %}
   10 :     <body>
   11 :         {% cms_toolbar %}
   12 : 
   13 :         {% placeholder "content" or %} Nothing is coming through... {% endplaceholder %}
   14 :     </body>
   15 :  {% endblock content %} 
   16 : 
   17 : 
   18 : ```


  [1]:[Traceback Image][1] https://i.stack.imgur.com/PkHi9.png

【问题讨论】:

  • 检查内容是否在您的主模板中
  • 你能分享你的admin/merchant/base.html吗?
  • 是的,我的 base.html 中有它
  • 整件事?超过 300 行
  • @EricMartin 基本上我想要的是仅在保留我的基本导航和内容(如果可能的话)的同时使用该模板中的 cms 编辑功能,所有其他模板都可以正常工作。

标签: django django-cms


【解决方案1】:

我想出了一种方法来在我的模板中使用 iframe 来获得我想要的功能

<iframe src="{% url 'vendor:cms-index' %} width="100%" height="80%" />

def cms_index_view(request, *args, **kwargs):
   from cms.page_rendering import _render_welcome_page
   return _render_welcome_page(request)

对于在没有达到要求的代表次数的情况下发布答案,我深表歉意。只是觉得它对其他人有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-24
    • 2017-05-14
    • 2010-09-21
    相关资源
    最近更新 更多