Django初级手册6-静态文件

用Django加载外部文件

在Django中iamges,JS或者CSS通称为static文件

定制APP的外观

一般放在应用目录下的static/polls/目录下,下为polls/static/polls/style.css

li a {
    color: green;
}

CSS语法,表项的颜色为绿色;
在模版文件polls/templates/polls/index.html开始添加

{% load staticfiles %}

<link rel="stylesheet" type="text/css" href="{% static 'polls/style.css' %}" />

第一行表示从staticfles模版库中加载{% static %}模版标签。
第二行为HTML标签,表示链接一个外部样式表
在CSS中增加,来给应用的主页添加背景。

body {
    background: white url("images/background.gif") no-repeat right bottom;
}
posted @ 2014-02-28 09:35  Solon Tan  阅读(182)  评论(0编辑  收藏  举报