【问题标题】:placeholder not working in django-cms占位符在 django-cms 中不起作用
【发布时间】:2013-01-22 13:35:13
【问题描述】:

我正在使用 django cms 开发一个站点,配置了一切并且工作正常,下面是我的代码文件

settings.py

   ........
   ........

TEMPLATE_CONTEXT_PROCESSORS = (
       'django.contrib.auth.context_processors.auth',
       'django.core.context_processors.i18n',
       'django.core.context_processors.request',
       'django.core.context_processors.media',
       'django.core.context_processors.static',
       'cms.context_processors.media',
       'sekizai.context_processors.sekizai',
)

CMS_PLACEHOLDER_CONF = {
    'terms_and_conditions': {
        'name': gettext('Terms & Conditions'),
        'plugins': ['TextPlugin'],
    },
}

CMS_TEMPLATES = (
       ('home.html', 'Home Page'),
)

........
.......

urls.py

from django.conf.urls import patterns, include, url
from django.conf.urls.defaults import *
from django.conf.urls.i18n import i18n_patterns
from django.conf import settings
from django.contrib import admin

admin.autodiscover()

urlpatterns = patterns('',
     url(r'^admin/', include(admin.site.urls)),
     url(r'^', include('cms.urls')),
)

base.html

{% load cms_tags sekizai_tags menu_tags %}
<html>
<head> 
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome to Services</title>
{% render_block "css" %}
</head>
<body>
{% cms_toolbar %}
    <div class="promoinner">
       {% block base_content %}{% endblock %} 
    </div>
  {% render_block "js" %}
</body>
</html>

home.html

{% extends "base.html" %}
{% load cms_tags %}

{% block base_content %}
   {% placeholder "terms_and_conditions" or  %}
       <p>This data should be present in the editor in editing mode before entering anything in to plugins, because this data is giving through html</p>
       <p>But when i tried to edit the placeholder i cant see the data(that we mentioned in tags of html file), i can able to see the placeholder and i can able to add some data in to text plugin </p>
   {% endplaceholder %}
{% endblock %}

这里所有的问题是,我们通过 html 文件中的p 标签提供一些数据,所以当我打开 url http://localhost:8000/?edit 时,我可以看到名为的占位符 Terms &amp; Conditions 正如我们在 settings.py 文件中提到的,但是我们通过标签在 html 文件中提供的数据不可编辑且无法看到,同时我可以使用 text 插件在占位符中添加一些文本.

谁能告诉我为什么home.html中通过html标签提到的数据不可编辑甚至看不到?

【问题讨论】:

    标签: python django content-management-system django-cms


    【解决方案1】:

    尝试在“base.html”或“home.html”中加载占位符标签(看起来像您丢失的“placeholder_tags”)...

    {% load cms_tags sekizai_tags menu_tags placeholder_tags %}

    【讨论】:

    • 您好,感谢您的回复,实际上我急切地等待有人回答这个问题。是的,我已将占位符标记添加到 base.html,但同样的问题是,当我添加任何占位符时,我可以使用插件将数据添加到其中。很好,但是当我们创建一个站点时,我们会用 html 来设计它,对吗?通过使用占位符,我们想动态编辑输入的数据,所以在这里我通过 html 标签给出了数据,但是当我尝试通过占位符编辑它时,实际上看不到。
    猜你喜欢
    • 2013-03-22
    • 2017-04-06
    • 2017-12-24
    • 2013-10-08
    • 2012-11-02
    • 2013-08-25
    • 2019-08-17
    • 2015-05-20
    • 2017-02-16
    相关资源
    最近更新 更多