I looked http://docs.djangoproject.com/en/dev/howto/static-files/ already, but am still confused on how to get css/image files loaded.
On my server, the images folder and css file are located at /srv/twingle/search
my urls.py
1 from django.conf.urls.defaults import *
2
3 # Uncomment the next two lines to enable the admin:
4 # from django.contrib import admin
5 # admin.autodiscover()
6
7 urlpatterns = patterns('twingle.search.views',
8 url(r'^$', 'index'),
9 url(r'^search/(?P<param>\w+)$', 'index'),
10
11 (r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
12 {'document_root': '/srv/twingle/search'}),
13
14 )
I try to access my css as follows,
<link rel="stylesheet" type="text/css" href="/site_media/style.css" />
That’s exactly how the tutorial says to do it, but it doesn’t work. Any suggestions?
You’ve closed the urlpatterns on line 10, so your site_media declarations are just sitting there, not attached to anything. Get rid of the extra close bracket on 10.
Edited to add You’ve also used the prefix argument, which is being applied to the static view as well. Do this: