【发布时间】:2017-12-12 17:32:55
【问题描述】:
我在 django 项目的 header.html 中使用引导索引文件。任何人都可以指出将引导文件链接到静态文件夹的修复程序或最简单的方法。需要在哪些地方做,怎么做?
另外,为了使用引导程序,我可以只使用索引文件而不是头文件吗?
我可以看到错误(如下),但不知道修复它的语法。我尝试过的路线是使用 Jinja 逻辑,而第一个错误就是在这条线上出现的。 (第 14 行)
当前错误:
Error during template rendering
In template C:\Users\User\Desktop\pythonsite\mysite\aboutme\templates\aboutme\header.html, error at line 14
Invalid block tag on line 14: 'static'. Did you forget to register or load this tag?
4 <head>
5
6 <meta charset="utf-8">
7 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
8 <meta name="description" content="">
9 <meta name="author" content="">
10
11 <title>Freelancer - Start Bootstrap Theme</title>
12
13 <!-- Bootstrap core CSS -->
14 <link href="{% static 'vendor/bootstrap/css/bootstrap.min.css' %}" rel="stylesheet">
15
16 <!-- Custom fonts for this template -->
17 <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
18 <link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
19 <link href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic" rel="stylesheet" type="text/css">
20
21 <!-- Plugin CSS -->
22 <link href="{% static 'vendor/magnific-popup/magnific-popup.css' &}" rel="stylesheet" type="text/css">
23
24 <!-- Custom styles for this template -->
更新: 我将 jinja 的静态和使用更改为最初在引导索引文件中的内容:例如
<link href="vendor/magnific-popup/magnific-popup.css" rel="stylesheet" type="text/css">
它运行网页,但没有 CSS>
我仍然无法弄清楚如何将 css 从此索引页面链接到模板文件夹以及如何/在哪里什么语法。
当前网站结构:
文件夹的名称是“aboutme”(主应用程序的名称) 里面是静态文件夹。 在静态文件夹中,我已经删除了引导下载的全部内容(例如字体、css 和 js 文件夹)
我有模板文件夹,其中有 aboutme 文件夹,其中是 header.html 和 home.html。 header.html 是我正在使用的文件(如下),试图引用 css/js 等,以便网站看起来和显示正确。
我只是使用:
<link href="/static/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
而不是
<link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
我是否在每种情况下都这样做?还是我应该使用神社逻辑?
【问题讨论】: