Reputation: 2560
I don't fundamentally understand how manage.py collectstatic works. The idea I had was you have the path
project/app/static/app/base.css
and run collectstatic and it copies them to a /staticfiles/ folder which can then be accessed by {{STATIC_URL}}. I've tried this and it doesn't seem to find base.css.
Here are my variables for reference:
basepath = os.path.split(os.path.abspath(__file__))[0]
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(basepath, 'staticfiles')
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}base.css" />
Which all leads up to a 404 error when trying to get the stylesheet:
"GET /base.css HTTP/1.1" 404 2255
Upvotes: 2
Views: 1023
Reputation: 55972
It seems collectstatic is copying it over fine.
I think you just need to use the {% static "base.css" %}
template tag instead of trying to access the STATIC_URL
variable
i don't think STATIC_URL
is available in the template scope.
you COULD access it doing something like
from django.conf import settings
settings.STATIC_URL
but {% static %}
tag does this for you. It seems the version of django is important 1.5 looks like it uses the {% static %}
tag, but early versions look like they support STATIC_URL
when you have RequestContext
registered.
Upvotes: 2