第一个Django App(六)

2020-03-08  本文已影响0人  小桥流水啦啦啦

静态文件

图片,JavaScript, CSS

django.contrib.staticfiles

定制app的外观

在polls下创建static目录。Django将在这个目录下查找静态文件。

STATICFILES_FINDERS设置包含一个发现列表,根据这个列表来查找静态文件 (来自于不同的源)

INSTALLED_APPS是一个默认的AppDirectoriesFinder查找静态文件的子路径。

再在static里面创建/polls/style.css文件。

编辑polls/static/polls/style.css文件:

li a {
color: green;
}

编辑polls/templates/polls/index.html文件。

{% load static %}

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

添加背景图片

继续编辑polls/static/polls/style.css文件:

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

上一篇 下一篇

猜你喜欢

热点阅读