Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  5] [ 2]  / answers: 1 / hits: 16156  / 9 Years ago, mon, august 17, 2015, 12:00:00

Well my template code.



<!DOCTYPE html>
<html>
<head>
{% load staticfiles %}
<script type=text/javascript src=http://code.jquery.com/jquery-latest.min.js></script>
<script type=text/javascript src={% static 'website/staffaddproblem.js' %}></script>
<title>Dashboard</title>
<link href={% static 'website/style.css' %} rel=stylesheet type=text/css/>
</head>
<body>
body
</body>
<html>


As you can see it has a css file. which is working properly, but java script file does not work.
when i load the page its source looks like this.
enter



When i click the link it loads the file too its there its linking fine but its not working . there is no problem in code js code working fine when written in same file.


More From » django

 Answers
26

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

[#65393] Thursday, August 13, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
neildrews

Total Points: 166
Total Questions: 103
Total Answers: 85

Location: Moldova
Member since Sat, Aug 6, 2022
2 Years ago
neildrews questions
Fri, Feb 18, 22, 00:00, 2 Years ago
Tue, Oct 12, 21, 00:00, 3 Years ago
Tue, Mar 23, 21, 00:00, 3 Years ago
Sun, Aug 16, 20, 00:00, 4 Years ago
;