Here are my settings:
STATIC_ROOT = "/home/tony/Documents/mysite/mysite/"
STATIC_URL = '/static/'
STATICFILES_DIRS = (
"/home/tony/Documents/mysite/mysite/static/",
)
And here I refer my stylesheet(This gives me an error):
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}/css/reset.css" />
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}/css/style.css" />
And the error in the log:
[06/Apr/2012 13:36:09] "GET /css/reset.css HTTP/1.1" 404 2193
[06/Apr/2012 13:36:09] "GET /css/style.css HTTP/1.1" 404 2193
How I thought I fixed it:
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}static/css/reset.css" />
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}static/css/style.css" />
And it worked until I made another view-:
from django.shortcuts import render_to_response
from django.template import RequestContext
def test(request):
return render_to_response('test.html')
And in the template I added the {% extends ‘base/base.html’ %} and what do I get in the logs? this:
[06/Apr/2012 13:46:55] "GET /test/ HTTP/1.1" 200 964
[06/Apr/2012 13:46:55] "GET /test/static/css/style.css HTTP/1.1" 404 2229
[06/Apr/2012 13:46:55] "GET /test/static/css/reset.css HTTP/1.1" 404 2229
Notice the /test/? It doesn’t load the css.
Any idea why?(I never had this problem with django1.3)
Thanks in advance 🙂
You’re not using
RequestContextto render your template, so the context processors aren’t being run and thereforeSTATIC_URLis empty.