I just started a new development server for a website I am working on and I can't seem to get the Django development server to serve the static files I have for CSS and other things. The CSS for the admin site loads fine. I am running it in a virtualenv sandbox.
In settings.py I've messed around with MEDIA_ROOT and MEDIA_URL.
So far for MEDIA_ROOT I've tried.
MEDIA_ROOT = '/home/wluw/wluw/wluw/media'
and
MEDIA_ROOT = os.path.join(os.path.dirname(__file__), 'media')
I changed my ADMIN_MEDIA_PREFIX to
ADMIN_MEDIA_PREFIX = '/admin_media/'
my MEDIA_URL looks like this
MEDIA_URL = '/media/'
and the urls.py section for the static files looks like this.
if settings.DEBUG:
urlpatterns += patterns('',
(r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
)
Here's the output from the dev server when I try to access the page.
[21/Jul/2011 21:19:25] "GET /media/css/style.css HTTP/1.1" 302 0
[21/Jul/2011 21:19:25] "GET /media/css/style.css/ HTTP/1.1" 404 2561
from django.conf.urls.defaults import patterns, include, handler500, handler404
from django.conf import settings
from django.contrib import admin
import d51_django_admin_piston
handler500 = 'radio.frontend.views.server_error'
admin.autodiscover()
d51_django_admin_piston.autodiscover(admin.site)
urlpatterns = patterns(
'',
(r'^logs/', include('radio.logs.urls')),
(r'^events/', include('radio.events.urls')),
(r'^station/', include('radio.station.urls')),
(r'^staff/', include('radio.staff.urls')),
(r'^admin/', include(admin.site.urls)),
(r'^accounts/login/$', 'django.contrib.auth.views.login'),
(r'^', include('radio.frontend.urls')),
)
if settings.DEBUG:
urlpatterns += patterns('',
(r'^media/(?P<path>.*)$', 'django.views.static.serve',
# {'document_root': settings.MEDIA_ROOT}),
{'document_root': settings.MEDIA_ROOT, 'show_indexes': True})
)
Here is my radio.frontend.urls
from django.conf.urls.defaults import *
urlpatterns = patterns('radio.frontend.views',
url(r'^$', 'home', name='home'),
)
Here is my settings.py settings.py
Everything was working fine on the production server having /media? being the url for css and other things.
Also none of the content in the database is being shown. Each page of the site is created with a base.html and a viewname.html. Only the base.html part is showing up. I am sure this is a topic for an other question though.
I've looked at a ton of other posts with people having the same problem and none of them provided a solution. I am completely stumped.
Any help would be greatly appreciated. Thanks