gpt4 book ai didi

javascript - 使用 django 模板引用外部文件

转载 作者:太空宇宙 更新时间:2023-11-03 17:55:38 24 4
gpt4 key购买 nike

我尝试在 django 模板的 head 标签中包含 Javascript 和 CSS 的外部文件,但它们不起作用。当我在关闭 body 标签之前放置它们时,它们工作得很好。为什么?另一个问题是,当我使用继承时, children 看不到我的外部文件。有人可以帮帮我吗?

<head>
{% load staticfiles %}
<link rel = "stylesheet" type = "text/css" href = "{%static 'postare/style.css' %}"/>
<link type = "text/css" href = "{% static 'postare/css/bootstrap.min.css'%}" rel = "stylesheet"/>

<script type = "text/javascript" src = "{% static 'postare/js/bootstrap.min.js' %}"></script>
<script type = "text/javascript" src = "{% static 'postare/jquery.js' %}"></script>
<script type = "text/javascript" src = "{% static 'postare/scripts.js' %}"></script>
</head>

最佳答案

我在 <html> 之前加载静态标签。我用了{% load static %}而不是 {% load staticfiles %}它对我来说没有任何问题。

关于javascript - 使用 django 模板引用外部文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26404414/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com