【问题标题】:import css using 'static' template in Django在 Django 中使用“静态”模板导入 css
【发布时间】:2016-12-13 22:53:02
【问题描述】:

我一直在使用以下方法将 JS 文件导入到我的模板中:

  <script src="{% static 'inventory/js/panel.js' %}" type="text/javascript"></script>

在导入 CSS 时使用

  <link href="{{ STATIC_URL }}common/css/form.css" rel="stylesheet" type="text/css">

你能告诉我如何像导入 JS 文件一样使用静态模板标签导入 CSS 文件吗?谢谢

【问题讨论】:

  • 为什么会有所不同?

标签: javascript python html css django


【解决方案1】:

和你的js差不多:

{% load staticfiles %}

<link href="{% static "css/base.css" %}" rel="stylesheet"/>

【讨论】:

  • 应该是&lt;link href="{% static 'css/base.css' %}" rel="stylesheet"/&gt;
  • @AndyM。没必要,因为标签处理是分开的
猜你喜欢
  • 2021-03-21
  • 1970-01-01
  • 1970-01-01
  • 2018-09-19
  • 2020-07-20
  • 1970-01-01
  • 2020-10-27
  • 2020-12-09
  • 1970-01-01
相关资源
最近更新 更多