On Tue, Jul 8, 2008 at 7:58 PM, foo <[EMAIL PROTECTED]> wrote: > > OK, I know this has been posted in the forums before, but for some > reason, I'm still struggling to get my CSS stylesheet applied to my > django templates. I'm hoping that if I post my configuration, someone > can point out what I'm missing. > > I have my django project at: /opt/python/django-apps/foo/ > In my settings.py file, I have MEDIA_ROOT set to /opt/python/django- > apps/foo/templates/media/ and MEDIA_URL set to http://localhost/media > > In my apache2.conf file, I have the following: > > # Django configuration > LoadModule python_module modules/mod_python.so > > <Location "/admin"> > SetHandler python-program > PythonHandler django.core.handlers.modpython > SetEnv DJANGO_SETTINGS_MODULE foo.settings > PythonDebug On > PythonPath "['/opt/python/django-apps/'] + sys.path" > </Location> > <Location "/contact"> > SetHandler python-program > PythonHandler django.core.handlers.modpython > SetEnv DJANGO_SETTINGS_MODULE foo.settings > PythonDebug On > PythonPath "['/opt/python/django-apps/'] + sys.path" > </Location> > > <Location "/media"> > SetHandler None > </Location> >
An alias directive to tell apache where to find your media is probably all you need. Assuming your apache's DocumentRoot is something other than your templates dir. <Location "/media"> SetHandler None </Location> Alias /media/ /opt/python/django-apps/foo/templates/media/ Also putting your media dir in your templates dir is kind of odd. Usually it's at the top of the project directory. Then set MEDIA_URL='/media/' you don't need 'http://localhost'. > In my base.html file, I reference the stylesheet as <link > rel="stylesheet" type="text/css" href="media/style.css" > media="screen" /> Finally in your templates use '/media/foo' not 'media/foo', that way it doesn't matter what location you are serving from, /media/ will work. > When I point my browser at http://localhost/contact, all I get is a > blank page... no style and no text. The contact.html template is > below: > > {% extends "base.html" %} > > {% block title %} > - Contact Us > {% endblock %} > > {% block content %} > <p>some content...please show up</p> > {% endblock %} > > I'm not sure if there not being any text is related to the CSS problem > or not. I haven't spent any time troubleshooting that just yet, but I > thought I'd throw it in for good measure. > > Any help that anyone can give is greatly appreciated! > Also don't forget to set DEBUG=True in your settings.py and check your error log for more info. -- Milan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---