I don;t know why my css doesn't work.

30 views
Skip to first unread message

Safari

unread,
Jan 24, 2012, 8:29:30 AM1/24/12
to Django users
Of course, i don't have any errors. However css is not working. Please
help me.

main.html===============================
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="/media/css/style.css" type="text/
css" />
<title> {{page_title}} </title>
</head>
<body>
<h1>{{page_title}}</h1>
</body>
</html>

settings.py===============================
import os

ROOT_PATH = os.path.dirname(__file__)

MEDIA_ROOT = ROOT_PATH + '/media/'
MEDIA_URL='/media/'
ADMIN_MEDIA_PREFIX = '/media/admin/'

urls.py===============================
import os

ROOT_PATH = os.path.dirname(__file__)
urlpatterns = patterns ( ...
, r'^media/(?P<path>.*)$',
'django.views.static.serve', {'document_root':ROOT_PATH+'/media/'}),
... )
style.css===============================
body
{
background-color:#b0c4de;
}
h1
{
font-size:x-large;
}

Mario Gudelj

unread,
Jan 29, 2012, 6:43:00 PM1/29/12
to django...@googlegroups.com
Hey,

Try setting:

SITE_ROOT = os.path.dirname(os.path.realpath(__file__))

Try changing MEDIA_URL and  MEDIA_ROOT to:


MEDIA_ROOT = os.path.join(SITE_ROOT, 'media')

That works for me on dev env as well as production.

Cheers,




--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


Reply all
Reply to author
Forward
0 new messages