问题描述
如何准确地逐步安装夹层主题?
How to install Mezzanine Theme exactly, step-by-step?
例如, Moderna免费主题.
推荐答案
前提条件:
0)版本控制
Python 2.7.6.
Django 1.6.10
Mezzanine 3.1.10
Moderna v.? (static content)
1)我使用 PythonAnywhere 进行托管
2)我按照这种方式安装夹层:此处,在底部有指向PythonAnywhere特定指南的链接
2) I followed this way to install Mezzanine: here, at the bottom there are links to PythonAnywhere specific guides
3)因此,初始状态为:夹层部署为空,具有默认主题.
3) So, initial state is: Mezzanine is deployed, empty, with default theme.
4)[可选]收集了基本模板(原样约有80个)
4) [optional] Basic templates are collected (~80 of them it was)
5)静态是通过 python manage.py collectstatic
1.将Moderna添加到项目中
这是一个简单的步骤.
-
您应该转到主题主题的网站(对于Moderna,它是此处)并下载它.这将是一个Django应用,可能已压缩到存档中.
You should go to site with theme (for moderna it's here ) and download it. It will be a Django App, probably zipped into archive.
如果压缩了应用程序,则将其解压缩.
If app is zipped, unzip it.
将其移动到夹层项目文件夹(该文件夹由命令 mezzanine-project myproject
创建)
Move it to your Mezzanine project folder (the one, which got created by command mezzanine-project myproject
)
文件夹结构应变为:
myproject/
+-deploy/
+-static/
+-templates/ [in case you chose to collect them]
+-moderna/ [our new theme]
|
+-__init__.py
+-settings.py
+-urls.py
+-manage.py
+-wsgi.py
|
+-[some other things]
2.更改settings.py
-
打开夹层项目的settings.py
open settings.py of your Mezzanine project
在settings.py第一个记录中将moderna/模板添加到TEMPLATE_DIRS中.关键是为模板加载器提供新的指导-现在他们首先寻找现代的模板.现在应该看起来像这样:
add moderna/templates to TEMPLATE_DIRS in settings.py 1st recor. The point is to give new directions to template loaders - now they 1st look for templates in moderna. Should now look like this:
TEMPLATE_DIRS = (
os.path.join(PROJECT_ROOT, "moderna/templates"),
os.path.join(PROJECT_ROOT, "templates"),
)
首先,
将settings.py中的moderna应用添加到INSTALLED_APPS(我想,这是用于Moderna的视图,模型等-模板的后端)
add moderna app to INSTALLED_APPS in settings.py above all (I presume, that's for Moderna's views, models etc. - backend for templates)
3.新的静态文件
- 再次收集静态-现在它将获取moderna的静态
4.URLConf
-
在urls.py中,使用为/(根url)选择的DIRECT_TO_TEMPLATE,它应如下所示:
in urls.py, use DIRECT_TO_TEMPLATE selected for / (root url), it should look like this:
urlpatterns += patterns('',
url("^$", direct_to_template, {"template": "index.html"}, name="home"),
("^", include("mezzanine.urls")),
...
5.重新加载
我猜测某些服务器会自动获取新设置和网址.那些不应该手动重新加载的内容可以赶上来并开始显示您美丽的新主题.
I guess some servers would pick up new settings and urls automatically. Those which don't should be reloaded manually to catch up and start showing your beautiful new theme.
6.自定义开始
- 现在,您可以通过
myproject/moderna/templates/
文件夹中的base.html
和index.html
文件开始自定义Moderna主题./li>
- Now you can start customizing Moderna theme via
base.html
andindex.html
files inmyproject/moderna/templates/
folder.
后记
我欢迎进行任何更正和扩展,我不是夹层定制方面的专家,并且该主题有很多滑坡.
I welcome any corrections and extensions, I'm not an expert in Mezzanine customization and the topic has many of slippery slopes.
这篇关于如何部署:安装夹层主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!