Django入门笔记【六】

入门笔记翻译整理自:https://docs.djangoproject.com/en/1.8/

*该笔记将使用一个关于投票网络应用(poll application)的例子来阐述Django的用法。

*静态文件(static files):images, JavaScript, CSS

1. 自定义应用外观(look and feel)

创建polls/static目录。Django的STATICFILES_FINDERS会寻找静态文件。在static目录下,创建polls/style.css文件。

在polls/static/polls/style.css中添加:

1 # polls/static/polls/style.css
2 
3 li a {
4     color: green;
5 }

在文件polls/templates/polls/index.html顶部添加:

1 #polls/templates/polls/index.html
2 
3 {% load staticfiles %}
4 
5 <link rel="stylesheet" type="text/css" href="{% static 'polls/style.css' %}" />

2. 添加背景图片 

在polls/static/polls下创建images目录,在其中放入background.gif。对style.css添加:

1 body {
2     background: white url("images/background.gif") no-repeat right bottom;
3 }

 

-- The End --

 

posted @ 2015-06-25 12:43  py_drama  阅读(107)  评论(0编辑  收藏  举报