【发布时间】:2015-09-18 23:08:24
【问题描述】:
我的目的是将现有项目中的静态页面(关于我们、联系我们等)转换为管理员可编辑页面。我已按照tutorial 的说明开始工作,但似乎没有得到任何结果。到目前为止,执行python manage.py cms check 似乎表明我已经完成了所有设置。但我似乎没有得到正确的网址。这里说
您需要在末尾包含“cms.urls”urlpatterns url 模式。
我的网址如下:
urlpatterns = patterns('',
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
# Main site
url(r'^', include('website.urls')),
url(r'^', include('cms.urls')),
)
if settings.DEBUG:
import debug_toolbar
urlpatterns = patterns('',
url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
url(r'', include('django.contrib.staticfiles.urls')),
url(r'^__debug__/', include(debug_toolbar.urls)),
) + urlpatterns
当我输入http://localhost:8000?edit 时,cms 工具栏/菜单没有出现。当我使用 ?edit 为 url 添加后缀时,继承了我在下面创建的模板的页面也没有显示任何用于编辑的占位符。
知道我哪里做错了吗?
{% load cms_tags sekizai_tags %}
<!doctype html>
<html>
<head>
{% include "head.html" %}
{% block page_specific %}
{% endblock %}
{% render_block "css" %}
{% render_block "js" %}
</head>
<body>
<!--{% include "floating_login.html" %}-->
<section id="subpage_wrapper">
{% with include_ribbon=1 %}
{% include "nav_base.html" %}
{% endwith %}
<div id="sub_wrapper_white">
{% placeholder "feature" %}
{% block static_content %}
{% endblock static_content %}
</div>
<div id="sub_wrapper_red"></div>
<div id="sub_wrapper_yellow"></div>
</section>
</body>
</html>
【问题讨论】:
-
顺便说一句,
http://localhost:8000?edit无论如何都不会工作。它必须是http://localhost:8000/?edit。 -
谢谢,也试过了,但是主页还是没有以前的样子。
-
@goh 你确定你的尝试最终不会被路由到
website.urls吗?如果其中的任何内容与您尝试访问的 URL 匹配,则 Django CMS 将看不到该请求。 -
你错过了
{% cms_toolbar %}(最好是在<body>之后)让?edit工作
标签: django django-cms