2011-11-28 51 views
2

我想用此主题替换Pinax的默认主题:https://github.com/pinax/pinax-theme-bootstrap但我不确定我是否理解快速启动指令。你能给我一些提示吗?pinax的安装主题

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. 

我不明白他们的意思。我在文件settings.py中看到STATICFILES_DIRS和TEMPLATE_LOADERS,这意味着我必须将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”,那么应该包含“footer”和“nav”块?

Your pages should have blocks "head_title" and "body" and should extend "site_base.html". 

所以我想用这个主题的任何网页,我必须有块“head_title”和“身体”,并应扩大“site_base.html”。如果我有一个已经扩展了“site_base.html”的“base.html”,我是否必须再次扩展?

The url name "home" should be defined as the homepage. 

不确定。

请给我一些建议,谢谢!

+0

我已经使用setup.py install命令安装了它。 –

回答

0

这里的需求文件是什么?

这是可选的最佳做法。如果你想知道更多,这里是我前段时间写的一篇文章:http://dev.chocolatpistache.com/blog/2009/11/04/pinax-virtualenv-setuptools-pip-easy_install-and-requirementstxt/

确保模板加载程序和静态文件查找程序都包含应用程序目录。我不明白他们的意思。我看到在文件settings.py STATICFILES_DIRS和TEMPLATE_LOADERS

你TEMPLATE_LOADERS有 “django.template.loaders.app_directories.load_template_source”。这是“模板的应用程序加载器”。你需要检查STATICFILES_FINDERS。无论如何,这些设置应该默认打开。

将“apps.pinax-theme-bootstrap”添加到TEMPLATE_LOADERS显然是错误的。它应该在某个时候破坏你的网站。

所以我必须把扩展“theme_base.html”放在“site_base.html”里面。如果之前没有“site_base.html”,那么应该包含“footer”和“nav”块?

只需在yourproject/templates/site_base.html中复制theme_base.html这会让您更轻松。

链接关于模板继承:

https://docs.djangoproject.com/en/dev/topics/templates/#tags(约合部分“块和扩展” http://dev.chocolatpistache.com/blog/2009/07/15/template-inheritance-explained/

所以我想用这个主题的任何网页,我必须有块“head_title”和如果我有一个已经扩展了“site_base.html”的“base.html”,是否必须再次扩展一次?

你的temp迟到“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主题,引导。

耐心和毅力我的朋友,这是一个很长的路到顶部,如果你想摇滚:)

1

我知道。 Pinax的文档可能会让一个人疯狂......我想,无论如何,请让我们感激不尽。首先,创建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>&copy; Myself, 2014</p> 
      </footer> 
     </div> 

{% endblock %} 

则...

URL名称 “家” 应该被定义为主页。

这只是表示在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具有以下行:

你觉得这是要解决url "home"如果您还没有将您的任何网址标记为home

这也回答了有关网站名称的问题。您必须安装Django站点,然后将定义SITE_NAME