Friday, December 30, 2011

Unable to display static content.

Hi All,

I am just learning Python and Django. I am able to see the webpage but
css and images are not picked up.

Configuration as below:

Linux Ubuntu 11.04
Python 2.7.2
Django 1.3.1

I have setup Django using VirtualEnv. I am using PyCharm and my Django
project is pointing to the VirtualEnv Django installation.

In firebug, I am getting 404 for css and images.

Project Structure.

from django.conf.urls.defaults import patterns, include, url
import settings
from talenthunt.web import views

urlpatterns = patterns('',
url(r'^search-form/$', views.search_form),

if settings.DEBUG:
urlpatterns += patterns('',
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT}))
def rel(*x):
return os.path.join(os.path.abspath(os.path.dirname(__file__)),
*x )

MEDIA_ROOT = rel('media')
MEDIA_URL = '/media/'

STATIC_ROOT = rel('static')
STATIC_URL = '/static/'

ADMIN_MEDIA_PREFIX = '/media/admin/'

Only pasting relevant code from

<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>Organic Web Design</title>
<link href="{{ MEDIA_URL }}stylesheets/common.css"
rel="stylesheet" type="text/css" />

Any help will be much appreciated.


You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment