Django Utiles for EPFL Sites

django_epfl的Python项目详细描述


本页将讨论django的epfl模板。这些模板有 是为了反映“web2010”Link graphical chart of EPFL而开发的。

要使用这些模板,请将django_epfl添加到INSTALLED_APPS。那么你 可以通过添加^{tt3}继承基模板$ 在模板中。

可用块列表

以下所有块都在epfl模板中。每个块显示在 它的上下文和旁边有它的角色描述。

  • <html>
    • <head>
      • additional_meta : Place here all the additional meta in the HTML form
      • additional_links : Same for the links to additional resources
      • additional_css : Here for the CSS (don’t place CSS under additional_links to improve clarity and template inheritance)
      • additional_js : All JS that need to be loaded in the head section
      • page_title : If using the ^{tt4}$ var is not the best option, you can use this block to set the page title
    • </head>
    • <body>
      • header : Here is the header include. By default, the header is in English. (file: ^{tt5}$) To see the other options, take a look the package doc<http://kis-doc.epfl.ch/django/template.html#change-header-language-search-option>.
      • <div id=”main content”>
        • breadcrumbs : It is where you will put the “EPFL > Project > Section” navigation style.
        • languages : Links in the top right corner that permit the user to switch between languages.
        • <h1>
          • title : Area for the title of the project and (in general) its acronym.
        • </h1>
        • main-navigation : Area that contains droplists and all the navigation for the project.
        • tools : Space for the tools like RSS feed button, share button and so on.
        • <div id=”content”>
          • content : Contains the main content for the page.
        • </div>
        • <div id=”right-col”>
          • right_column : Contains the secondary content in the right column. If empty, the template will automatically switch to 1-column mode and the “right-col” div will not be displayed.
        • </div>
        • footer : Area for general contents like contact link, copyright, …
      • </div>
      • additional_js_ajax : Place JS that don’t need to be loaded first.
    • </body>
  • </html>

可用变量列表

目前,只有titlevar(表示页面标题)是 可用。注意不要与大的title块混淆 页面上的黑色标题。

注意

如果设置了title var,则不会显示page_titleblock。

使用EPFL错误页

为了处理epfl 404错误页,必须修改文件 views.py然后放入这个:

from django.shortcuts import render_to_response

def error404(request):
    return render_to_response('django_epfl/errors/404.fr.html')

然后,在您的urls.py

from django.conf.urls.defaults import handler404

handler404 = 'django_site.views.error404'

要处理500个错误,这是相同的逻辑。因为错误像 503不是本机支持的,您必须在 代码。关于如何做到这一点的一些解释 here

https://docs.djangoproject.com/en/1.3/ref/request-response/#ref-httpresponse-subclasses 如果您需要返回一些具有已定义状态的httpresponse,也可以为您提供帮助 代码。

注意

如果DEBUG设置为,则不会显示404和500错误页 True

更改标题语言/搜索选项

可以使用header块更改头。

templates/template_incdir中有四个不同的头:
  • header.fr.html
  • header.en.html
  • header-no-local-search.fr.html
  • header-no-local-search.en.html

显然,在标题名中,fr表示法语和en英语。这个 no local search头的版本不包含搜索选项“on” 这个网站”。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java传递位置作为FragmentPagerAdapter中片段的参数   html Java Jsoup循环打印   java如何使用FileOutputStream写入数据而不丢失旧数据?   java在测试用例类/方法中执行sql before/after/in   java在javafx中注册鼠标处理程序,但处理程序不是内联的   Android嵌入了一个C++库的java代码,不需要TopPLE程序来嵌入它?   片段类内部的java ProgressBar导致setMax方法出现NullPointerException?   带有google app engine的java Activator Play框架   java如何解析星级而不是字符串?   java如何在基本实体中定义通用主键字段?   通过扩展实现Java克隆   使用CipherOutputStream的java递归加密提供一个空字节[]   在运行时提取字段值的Java服务   Java 11和spring boot从spring boot应用程序的fat jar中的依赖项jar加载资源   java尝试使用J2SE枚举所有可用的Wifi网络   使用Java库进行SWIFT MT消息解析   java拆分非逗号分隔的字符串   java为什么toString()不能是静态方法?   java在连接到集群数据库时遇到mongo异常   java访问Hashmap中存储的json有效负载值