Reputation:
I'm using Django 1.5 And I'm having problems with static files.
statiic settings :
STATIC_ROOT =''
STATIC_URL = '/static/'
STATICFILES_DIRS = ('C:/Python33/Django-1.5/django/bin/pollbooth/templates/files/static',)
I have included django.contrib.staticfiles in INSTALLED APPS
After manage.py runserver
, when i open localhost or 127.0.0.1:8000, my home page loads all the static files..
But when I click on another link, that page does not load the static file.
You can see the command box image from this link http://farm9.staticflickr.com/8238/8599256147_aa6875d657_b.jpg
Can you tell me where I'm going wrong?
Upvotes: 2
Views: 1546
Reputation: 301337
Your static url is /static/
. The about page looks for static files at /about/static
, which will of course, not be found. Change the static reference in your about page.
Refer to static files like the examples given below, in your templates:
{{ STATIC_URL }}js/application.js
{{ STATIC_URL }}css/app.css
{{ STATIC_URL }}appname/js/app.js
Upvotes: 4
Reputation: 616
In your templates, change your links to:
<link rel="stylesheet" href="{{ STATIC_URL }}js/bootstrap.min.js" />
Right now you probably have the following (notice a missing slash before static/
):
<link rel="stylesheet" href="static/js/bootstrap.min.js" />
Upvotes: 2
Reputation: 22459
How are you loading static files in your templates? I guess your directory structure might be wrong.
/project_root/
manage.py
/project/
/static/
/css/
/js/
/img/
/media/
settings.py
urls.py
/app/
/static/
/app/ <-- important when using app specific static files
/css/
/js/
/img/
Upvotes: 0