问题描述
我的目的是将现有项目中的静态页面(关于我们,与我们联系等)转换为可管理页面。我已按照中的说明进行操作开始,但似乎没有任何结果。到目前为止,执行 python manage.py cms检查
似乎表明我已完成所有设置。但是我似乎没有正确输入网址。它说在这里
My purpose is to convert static pages (about us, contact us etc) in my existing project to admin editable pages. I have followed the instructions at the tutorial to get things started but don't seem to get any results. So far performing python manage.py cms check
seems to indicate I got everything set up. But I don't seem to get the urls right. It says here
我的网址如下:
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工具栏/菜单没有出现。当我在URL后面加上?edit后,继承了我在下面创建的模板的页面也没有显示任何可编辑的占位符。
When I type http://localhost:8000?edit
, the cms toolbar/menus didn't show up. Neither do the page that inherited the template I created below shows any placeholder for editing when I suffixed the url with ?edit.
知道我哪里出了错吗?
{% 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>
推荐答案
两件事,删除,我认为是,您的项目网址,否则可能会引起一些问题。但是,如果您需要它,请不要仅匹配基本模式,因为我认为这是一种不好的做法,直到您在该文件中进行了很多特定的模式匹配,而这些匹配不太可能破坏CMS URL。
Two things, remove, what I assume to be, your project URLs as that might cause you some issues. But if you need it, don't just match the base pattern as I consider that bad practise until you do a lot of specific pattern matches in that file which aren't likely to break the CMS URLs.
然后将 {%cms_toolbar%}
标记添加到基本模板中,以确保工具栏显示&您可以与CMS进行交互。
Then add the {% cms_toolbar %}
tag to your base template in order to ensure the toolbar displays & you can interact with the CMS.
urls.py
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'^project/', include('website.urls')),
url(r'^', include('cms.urls')),
)
base.html
{% load cms_tags sekizai_tags %}
<!doctype html>
<html>
<head>
{% include "head.html" %}
{% block page_specific %}
{% endblock %}
{% render_block "css" %}
{% render_block "js" %}
</head>
<body>
{% cms_toolbar %}
<!--{% 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>
这篇关于如何开始将django-cms集成到现有项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!