问题描述
我对Django CMS完全陌生,并且对此问题感到困惑.
I'm completely new to Django CMS and I'm stuck with this issue.
我向现有的Django项目添加了一个新模块,并创建了一个新的HTML页面.这是 settings.py
I have added a new module to an existing Django project and created a new Html page. This is the templates configuration in settings.py
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'site_cms', 'templates'),
],
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.template.context_processors.i18n',
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.template.context_processors.media',
'django.template.context_processors.csrf',
'django.template.context_processors.tz',
'sekizai.context_processors.sekizai',
'django.template.context_processors.static',
'cms.context_processors.cms_settings',
'core.context_processors.request_info',
],
'loaders': [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
'django.template.loaders.eggs.Loader'
],
},
},
]
在新页面中,我将扩展网站的首页,就像我看到其他页面一样.这是主页 home.html (/core/templates/core/home.html):
In the new page, I'm extending the home page of the website as I've seen other pages do. This is the home page home.html (/core/templates/core/home.html):
{% load i18n easy_thumbnails_tags static %}
<!DOCTYPE html>
<html lang="en">
<head>
{% load staticfiles i18n menu_tags%}
</head>
<main>
<div class="container">
{% block content %}
这是我的新页面 newpage.html (/newpage/templates/newpage/newpage.html)
This is my new page newpage.html (/newpage/templates/newpage/newpage.html)
{% extends "home.html" %}
{% load easy_thumbnails_tags i18n static core_filters bootstrap4 %}
{% block content %}
{% load bootstrap4 %}
<div class="container">
创建新页面后,我通过Django CMS栏将其添加到网站主菜单中.我将页面的模板选择为父母(家庭)使用的模板.我看到这仅在数据库中进行更改.好的,现在我在主页菜单和Django CMS模块中都有此页面.
After creating the new page, I added it to the website main-menu through the Django CMS bar. I selected the template for the page to the one the parent (home) uses. I see this makes changes only in Database. OK, so now I have this page in the main-page menu, and in the Django CMS module.
我的问题是我无法从Django CMS栏中编辑页面的结构.当我点击修改"时,按钮,我看到结构图标(www.localhost:8000/newpage/?structure),但是该按钮未激活.我希望能够将小部件添加到此页面.我该怎么做?如何激活可修改性的结构?
The problem I have is that I cannot edit the structure of the page from the Django CMS bar. When I click on "Edit" button, I see the structure icon (www.localhost:8000/newpage/?structure), but the button is not active. I want to be able to add widgets to this page. How can I do that?How can I active the osibility to modify the structure?
在这个项目中,我看到一些页面具有修改页面结构的可能性,而另一些则没有.也许相关,当我检查具有这种可能性的其他页面的来源时,会看到:
On this project, I see some pages have this posibility to modify the structure of the page, and others don't. Maybe relevant, when I check the source of other pages with this posibility, I see:
'request': {
'language': 'en',
'model': 'cms.page',
'page_id': '3',
'pk': '3',
'url': '/admin/cms/page/resolve/',
'toolbar': '/admin/cms/usersettings/cms-toolbar/'
},
在新页面上,我看到:
'request': {
'language': 'en',
'model': '',
'page_id': '103',
'pk': '',
'url': '/admin/cms/page/resolve/',
'toolbar': '/admin/cms/usersettings/cms-toolbar/'
},
我使用Python 3.6.9,Django 1.11.17和django-cms 3.5.3.我知道我可能会缺少一些相关的信息/代码来显示.请问,我会发表.
I use Python 3.6.9, Django 1.11.17 and django-cms 3.5.3.I know I can be missing some relevant info/code to show. Please ask, I'll post.
推荐答案
您需要加载CMS的可编辑部分.首先,这将是一个占位符,以便您可以通过结构视图添加内容.
You need to load the editable parts of CMS. Primarily this would be a placeholder so that you can add content via the structure view.
将 newpage.html
更改为类似的内容
{% extends "home.html" %}
{% load cms_tags easy_thumbnails_tags i18n static core_filters bootstrap4 %}
{% block content %}
{% load bootstrap4 %}
<div class="container">
{% placeholder "content" %}
</div>
{% endblock %}
现在您将看到一个名为"content"的占位符.在您可以向其中添加插件的结构视图中.
Now you'll see a placeholder called "content" in the structure view which you can add plugins to.
这篇关于Django CMS-无法修改新添加的网页的结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!