2

I'm having a lot of trouble getting all my static files to serve up. In my settings.py, I have:

STATIC_URL = '/static/'

I'm using Django 1.6, and according to the official documentation https://docs.djangoproject.com/en/dev/howto/static-files/

Since I have debug=True, this should suffice.

Then in my templates:

<link type="text/javascript" href="{% static 'jquery-1.11.1.js' %}" />
<link type="text/javascript" href="{% static 'jquery-1.11.1.min.js' %}" />
<link rel="stylesheet" type="text/css" href="{% static 'bootstrap.min.css' %}" />
<link rel="stylesheet" type="text/css" href="{% static 'jumbotron.css' %}" />
<link rel="stylesheet" type="text/css" href="{% static 'custom.css' %}" />
<link rel="stylesheet" type="text/css" href="{% static 'simple-sidebar.css' %}" />

All the CSS works fine. When I load my page, looking in Chrome's developer tools, they're coming from /static, and I have all these files stored in the same dir. But the .js files are not loading at all. They work fine if I link to the CDN.

timo.rieber
  • 3,572
  • 3
  • 30
  • 44
Steven Werner
  • 123
  • 1
  • 3
  • 11

2 Answers2

2

As I said in the comments, with <script> tags, they shouldn't be self-closing so

<script type="text/javascript" src="{% static 'jquery-1.11.1.min.js' %}"></script>

note the <script ...></script> instead of <script .../>

This is probably why your subsequent link tags aren't being processed properly

Community
  • 1
  • 1
Basic
  • 25,747
  • 24
  • 111
  • 193
1

What is link in

<link type="text/javascript" href="{% static 'jquery-1.11.1.min.js' %}" />

It should be

<script type="text/javascript" src="{% static 'jquery-1.11.1.min.js' %}"></script>
Lorenz Meyer
  • 18,330
  • 22
  • 72
  • 114