我想用这个主题替换默认的Pinax主题:https://github.com/pinax/pinax-theme-bootstrap,但是我不确定我是否理解快速启动指令。你能给我点提示吗?
Include "pinax-theme-bootstrap" in your requirements file and "pinax_theme_bootstrap" in your INSTALLED APPS.这里的需求文件是什么?
Make sure both template loaders and staticfiles finders includes app directories.我不明白他们的意思。我在文件STATICFILES_DIRS和TEMPLATE_LOADERS中看到了settings.py,它们意味着我必须将pinax_theme_bootstrap目录放在apps文件夹中,并包含指向该目录的链接。如下所示:
STATICFILES_DIRS = [
os.path.join(PROJECT_ROOT, "media"),
os.path.join(PINAX_ROOT, "media", PINAX_THEME),
os.path.join(PINAX_ROOT, "apps", pinax-theme-bootstrap),
]
TEMPLATE_LOADERS = [
"django.template.loaders.filesystem.load_template_source",
"django.template.loaders.app_directories.load_template_source",
"apps.pinax-theme-bootstrap",
]
Site name comes from Sites fixture.我完全不明白他们的意思。
Your "site_base.html" should extend "theme_base.html" and should provide "footer" and "nav" blocks (the latter should just be a ul of li of a links).因此,我必须将"theme_base.html“扩展放在"site_base.html”中。如果以前没有,应该在"site_base.html“中同时包含”脚注“和"nav”块吗?
Your pages should have blocks "head_title" and "body" and should extend "site_base.html".因此,在我想要使用这个主题的任何页面中,我都必须有块"head_title“和"body”,并且应该扩展"site_base.html“。如果我有一个已经扩展了"base.html“的"site_base.html",那么我还需要再扩展一次吗?
The url name "home" should be defined as the homepage.不确定。
请给我一些建议,谢谢!
发布于 2014-04-17 03:33:16
我知道呀。皮纳克斯的文件会让人发疯..。我想,我们还是要心怀感激吧。
首先,创建templates/site_base.html。示例:
{% extends "theme_bootstrap/base.html" %}
{% block nav %}
<ul class="nav navbar-nav navbar-left">
<li><a href="#">Link 1</a>
<li><a href="#">Link 2</a>
</ul>
{% endblock %}
{% block footer %}
<div class="container">
<hr>
<footer>
<p>© Myself, 2014</p>
</footer>
</div>
{% endblock %}然后..。
网址名"home“应定义为主页。
这意味着在urls.py中,您的主页应该被标记为name='home'。例如,
url(r'^$', 'app.views.index', name='home'),否则,您将得到错误,如
NoReverseMatch at /account/signup/
Reverse for 'home' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []实际上,base.html有以下一行:
{% block site_brand %}<a class="navbar-brand" href="{% url "home" %}">{{ SITE_NAME }}</a>{% endblock %}如果您没有将您的urls标记为url "home",您认为它将如何解决home
这也回答了关于网站名称的问题。您必须安装Django站点,然后才会定义SITE_NAME。
发布于 2011-12-21 16:15:13
这里的需求文件是什么?
这是一种可选的最佳做法。如果你想知道更多,下面是我不久前写的一篇文章:http://dev.chocolatpistache.com/blog/2009/11/04/pinax-virtualenv-setuptools-pip-easy_install-and-requirementstxt/
确保模板加载器和静态文件查找器都包括应用程序目录。我不明白他们的意思。我在文件STATICFILES_DIRS和TEMPLATE_LOADERS中看到了settings.py
你的TEMPLATE_LOADERS有"django.template.loaders.app_directories.load_template_source".这是“模板的应用程序加载程序”。你需要检查一下STATICFILES_FINDERS。默认情况下,这些设置应该是打开的。
在TEMPLATE_LOADERS中添加“apps.pinax主题-引导”是完全错误的。它应该会在某个时候破坏你的网站。
,所以我必须将扩展"theme_base.html“放在"site_base.html”中。如果以前没有,应该在"site_base.html“中同时包含”脚注“和"nav”块吗?
只需将theme_base.html复制到您的项目/模板/Sitebase.html中即可,这将使您更加容易。
有关模板继承的链接:
https://docs.djangoproject.com/en/dev/topics/templates/#tags (关于“块和扩展”http://dev.chocolatpistache.com/blog/2009/07/15/template-inheritance-explained/的部分)
所以在我想要使用这个主题的任何页面中,我都必须有块"head_title“和"body”,并且应该扩展"site_base.html“。如果我有一个已经扩展了"base.html“的"site_base.html",那么我还需要再扩展一次吗?
您的模板"article_detail.html“将类似于:
{% extends 'site_base.html' %}{# this is your copy of theme_base.html #}
{% block head_title %}{{ article.title }}{% endblock %}
{% block body %}
<h1>{{ article.title }}</h1>
<p>{{ article.body }}</p>
{% endblock %}我的建议是:安装Pinax并使用它的初学者项目,该项目默认具有pinax主题引导(以及大多数项目默认需要的许多东西)。
耐心和毅力,我的朋友,如果你想摇滚乐,这是一段很长的路。)
https://stackoverflow.com/questions/8290920
复制相似问题