Django Static js files not working

不羁岁月 提交于 2019-12-06 02:02:05
Abhyudit Jain

Have you changed the settings.py file to include staticroot?

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

Here's a part of my template which works with both js and css files.

{% load static %}
<html>
<head>
<link type="text/css" rel="stylesheet" href="{% static 'css/materialize.min.css' %}">
<link type="text/css" rel="stylesheet" href="{% static 'css/stylesheet.css' %}">
<script type="text/javascript" src="{% static 'js/jquery-1.11.3.min.js' %}"></script>
<title>

The directories are as follows:

 - static
     -js
         - jquery-1.11.3.min.js
     -css     
         - stylesheet.css
         - materialize.min.css
 - templates
     -index.html
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!