Django Mezzanine - 如何在每页上安装自定义模板?

时间:2015-02-03 10:12:20

标签: python django content-management-system mezzanine

这是文档:(对我来说不是很清楚)。 http://mezzanine.jupo.org/docs/content-architecture.html#page-templates

以下是dollydagr回答的问题: How to add a custom template page to mezzanine?

他/她提供的第三种方法很有意义,但我希望url slug magic能够工作而不是使用urls.py

如果我创建一个新的Mezzanine项目和一个名为theme的应用程序。 在theme文件夹中,我可以使用templatesbase.html创建index.html目录。

如果我现在转到管理员并创建一个名为blue的新富文本页面。 我需要做些什么来获取blue.html模板? (假设我目前只有base.htmlindex.html而没有其他内容。

我尝试了许多组合但没有成功。

更新(确实有效!):以下是获取网页自定义模板的最低步骤。

sudo pip install mezzanine
mezzanine-project myproject
cd myproject/
python manage.py createdb
python manage.py startapp theme
> Add the theme app to your installed apps in settings.py
mkdir theme/templates
mkdir theme/templates/pages
nano theme/templates/pages/blue.html
> Add text: This is the blue page
python manage.py runserver
> Go to admin (http://127.0.0.1/admin) and add top level page titled blue.
> Browse to http://127.0.0.1/blue

1 个答案:

答案 0 :(得分:3)

使用文件名theme/templates/pages/blue.html创建模板,它将用于包含blue slug的页面。