[英]aldryn hello world issue
我正在自學如何使用 Aldryn 來托管 django-cms 網站。 我一直在閱讀readthedocs站點上的應用程序開發教程,幾乎一直到最后。 當我運行aldryn project up
,出現錯誤提示我檢查日志。 我使用docker-compose logs web
檢查日志,並在日志末尾看到: django.core.exceptions.ImproperlyConfigured: CMS Plugins must define a render template (<class 'hello_world_ct.cms_plugins.HelloWorld'>) that exists: hello_world_ct/hello.html
出於某種原因,aldryn 項目似乎無法識別我在class HelloWorld(CMSPluginBase):
定義了 render_template 的臉。 當我注釋掉 render_template 時,日志給了我同樣的錯誤。
我已經完全按照教程告訴我的那樣設置了項目。 addons-dev 文件夾內的目錄樹是這樣的:
hello-world-ct/
├── addon.json
├── hello_world_ct
│ ├── admin.py
│ ├── cms_plugins.py
│ ├── cms_plugins.pyc
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── migrations
│ │ └── __init__.py
│ ├── models.py
│ ├── models.pyc
│ ├── templates
│ │ └── hello_world_ct
│ │ └── hello.html
│ ├── tests.py
│ └── views.py
├── LICENSE
├── MANIFEST.in
├── README.rst
└── setup.py
cms_plugins.py 文件如下所示:
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from cms.models.pluginmodel import CMSPlugin
class HelloWorld(CMSPluginBase):
model = CMSPlugin
render_template = "hello_world_ct/hello.html"
text_enabled = True
plugin_pool.register_plugin(HelloWorld)
...在我看來是正確的,但也許我遺漏了一些東西。
我有同樣的問題。 這是對我有用的解決方案。
在settings.py
文件中,將應用程序的模板文件夾添加到TEMPLATES
變量:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'your_core_app', 'core_app_templates_folder'),
os.path.join(BASE_DIR, 'hello_world_ct', 'templates'),
],
'OPTIONS': {
...
},
},
]
並將模板名稱添加到CMS_TEMPLATES
變量中:
CMS_TEMPLATES = (
('fullwidth.html', 'Fullwidth'),
...
('hello.html', 'Hello World CT'),
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.