Django 1.4: static file not found

I'm trying google but i cant fix my problem. Many people have this problem and tried to follow their instructions, but I still can not fix it. So, any problems with my configuration?

--- settings.py ----

PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
STATIC_ROOT = os.path.join(PROJECT_PATH, 'static')
STATIC_URL = '/static/'

TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.tz",
"django.contrib.messages.context_processors.messages")

--- views.py ---

render_to_response('authen/login.html',context_instance=RequestContext(request))

--- login.html ---

<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}styles/reset.css" />
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}styles/root.css" />

--- error ---

[16/Apr/2012 21:27:26] "GET /authen/login.php HTTP/1.1" 200 1391
[16/Apr/2012 21:27:26] "GET /static/styles/reset.css HTTP/1.1" 404 1652
[16/Apr/2012 21:27:26] "GET /static/styles/root.css HTTP/1.1" 404 1649 

--- urls.py ---

if settings.DEBUG:
    urlpatterns += patterns('django.contrib.staticfiles.views',
        url(r'^static/(?P<path>.*)$', 'serve'),
    )
+3
source share
2 answers

You are probably looking for:

https://docs.djangoproject.com/en/1.4/ref/contrib/staticfiles/#static-file-development-view

UPDATE: I see that you have a url template for static files. Do you have DEBUG = True in settings.py?

+3
source

I had the same problem, it could not find any static file. But with the Sophy SEM comment (see above) this worked:

Instead of installing

STATIC_ROOT = os.path.join(SITE_ROOT, 'static')

STATIC_ROOT = ''
STATICFILES_DIRS = ( os.path.join(SITE_ROOT, 'static'), )

. , - , .

0

All Articles