Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/347.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何将main.css链接到所有Django模板?_Python_Css_Django - Fatal编程技术网

Python 如何将main.css链接到所有Django模板?

Python 如何将main.css链接到所有Django模板?,python,css,django,Python,Css,Django,我希望能够从Django中的所有模板调用main.css中的类。目前,我将其存储在app_name/static/css/main.css中。如何将其链接到模板,以便只需向html元素添加一个类并应用该类?我将使用包含所有常用内容的基础模板(JQuery,main.css) 因此,您将有一个名为base.htmlwillall的模板,用于特定页面内容的基本内容和占位符: <html> <head> <link rel="stylesheet" type="t

我希望能够从Django中的所有模板调用main.css中的类。目前,我将其存储在app_name/static/css/main.css中。如何将其链接到模板,以便只需向html元素添加一个类并应用该类?

我将使用包含所有常用内容的基础模板(JQuery,main.css)

因此,您将有一个名为
base.html
willall的模板,用于特定页面内容的基本内容和占位符:

<html>
<head>
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}/css/main.css">
    {% block additional_header %}
    {% endblock %}
</head>
<body>
    {% block content %}
    {% endblock %}
</body>
</html>
。查找标题为
模板继承
的部分

{% extends 'base.html' %}
{% block content %}
This is specific content for your page
{% endblock %}