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,727
  • 3
  • 32
  • 47
Steven Werner
  • 165
  • 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
  • 26,321
  • 24
  • 115
  • 201
  • My pleasure. If our answers helped you, consider upvoting and/or accepting with the arrows and tick on the left. Welcome to SO and hope to see you around in future – Basic May 23 '14 at 06:56
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
  • 19,166
  • 22
  • 75
  • 121