Django静态文件引用错误 - 'static'. Did you forget to register or load this tag?
2018-01-20 17:23
639 查看
在我对一个网页配置静态文件的时候, 我想改变以往那种硬编码的方式, 改为动态引用.
于是, 我这么引用静态文件
<link rel="stylesheet" type="text/css" href="{% static 'css/D_searchword.css' %}" />
但是在测试的时候总是显示404我以为是配置问题, 在setting.py里面找了很久, 后来排除了
问题的原因是我没有在<head></head>加上 {% load staticfiles %}, 导致引用失败
后来我加上了, 成功
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<title>test</title>
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static 'css/D_searchword.css' %}" />
</head>tips: 别忘了格式
以上!
于是, 我这么引用静态文件
<link rel="stylesheet" type="text/css" href="{% static 'css/D_searchword.css' %}" />
但是在测试的时候总是显示404我以为是配置问题, 在setting.py里面找了很久, 后来排除了
问题的原因是我没有在<head></head>加上 {% load staticfiles %}, 导致引用失败
后来我加上了, 成功
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<title>test</title>
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static 'css/D_searchword.css' %}" />
</head>tips: 别忘了格式
以上!
相关文章推荐
- Django静态文件引用错误 - 'static'. Did you forget to register or load this tag?
- 解决错误:You need to use a Theme.AppCompat theme (or descendant) with this activity.
- org.apache.jasper.JasperException: Failed to load or instantiate TagExtraInfo class: org.apache.struts.taglib.bean.CookieTei错误解决方法。
- Android错误:You need to use a Theme.AppCompat theme (or descendant) with this activity.
- android studio编程时出现的错误:you need to use a theme.appCompat theme(or descendant) with this a
- 错误:You need to use a Theme.AppCompat theme (or descendant) with this activity.
- WTL出现GUID错误 Did you forget to pass the LIBID to CComModule::Init?
- jsp项目文件运行出现java.lang.ClassNotFoundException和Failed to load or instantiate TagExtraInfo class异常
- 关于“you need to use a theme.appcompat theme (or descendant) with this activity”错误
- 我的Android进阶之旅------>解决错误:You need to use a Theme.AppCompat theme (or descendant) with this activity.
- This application failed to start because it could not find or load the Qt platform plugin “windows”错误解决方法
- 用maven管理项目,后加入tomcat中出现以下错误Failed to load or instantiate TagLibraryValidator class:
- qt程序运行在树莓派错误解决This application failed to start because it could not find or load the Qt platform plu
- 【qt错误】This application failed to start because it could not find or load
- Android解决在清单文件里消除Bar报错:You need to use a 原来Theme.AppCompat theme (or descendant) with this activity.
- Android错误之:You need to use a Theme.AppCompat theme (or descendant) with this activity.
- WTL出现GUID错误 Did you forget to pass the LIBID to CComModule::Init?
- Django--static静态文件引用
- Android问题集锦之二十八:You need to use a Theme.AppCompat theme (or descendant) with this activity.
- This application failed to start because it could not find or load the Qt platform plugin “windows”错