tags:

views:

30

answers:

2

I have several CSS files listed in my base.html, and while one of them is loaded, everything else isn't, nor the javascript or images.

The following is a portion of base.html:

<html>
<head>
    <link href="/media/css/base.css" rel="stylesheet" type="text/css"/>        
    <link href="/media/css/home.css" rel="stylesheet" type="text/css"/>
    <link href="/media/css/slideshow.css" rel="stylesheet" type="text/css"/>
    <link href="/media/css/demos.css" rel="stylesheet" type="text/css"/>
    ...

with media being the folder in the base directory that contains the static files. When viewing the source of the page produced, base.css loads fine, but for everything else, I get Page not found: [Name of CSS file here]. As far as I can tell, there isn't any difference between base.css and home.css; the folder location, the file permissions...I just can't figure out why it can find one file and not the rest. Does anyone have any ideas what might be going on?

Settings.py

ROOT_DIR = os.path.abspath("")
ROOT_URL = 'http://url that will be used for running product/'


MEDIA_ROOT = ROOT_DIR + 'media/'
MEDIA_URL = ROOT_URL + 'media/'

urls.py

urlpatterns += patterns('django.views',
        url(r'^media/css/(?P<path>.*)$', 'static.serve',
            {'document_root': ROOT_DIR + 'media/css/'}, name='css-root'),
        (r'^media/images/(?P<path>.*)$', 'static.serve',
            {'document_root': ROOT_DIR + 'media/images/'}),
        (r'^media/scripts/(?P<path>.*)$', 'static.serve',
            {'document_root': ROOT_DIR + 'media/script/'}),
)
A: 

What is your MEDIA_ROOT set to? I'm surprised you are having to do more than just "/css/base.css" etc.

Justin Myles Holmes
MEDIA_ROOT is set to media.
Jesse J
...and how about MEDIA_URL?
Justin Myles Holmes
Same thing, but with the prefix of the URL that will be used in production. I'll edit my post with it.
Jesse J
And main urls.py?
sunn0
A: 

OK so we've got to the bottom of this now. Your MEDIA_URL setting is conflicting with the ADMIN_MEDIA_PREFIX setting - they are both set to `/media', and the admin one takes precedence.

Set MEDIA_URL to something else - /site_media, for example - and things should be happier.

Daniel Roseman