1

First time Django user. VERSION: 1.2.3

I am trying to set up my dev server to use static CSS files, but can't seem to get the settings quite right. I've looked at the Django documents and other threads here, but still no luck. I'm hopping another set of eyes will help me.

Here's what I'm using right now:

settings.py

DEBUG = True
MEDIA_ROOT = '/home/wade/myproject/static/'
MEDIA_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/media/'

TEMPLATE_LOADERS = (

'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
'django.template.loaders.eggs.Loader',
)

TEMPLATE_DIRS = (

'/home/wade/myproject/templates',
)

urls.py

from django.conf import settings

if settings.DEBUG:
urlpatterns += patterns('',
    (r'^static/(?P<path>.*)$', 'django.views.static.serve',
        {'document_root': settings.MEDIA_ROOT}),
)

.html

<link rel"stylesheet" type="text/css" 
    href="/static/style.css" />
6
  • "Not quite right" isn't very informative. What behaviour are you seeing? What do you expect to see? Do you get any error messages? Please see msmvps.com/blogs/jon_skeet/archive/2010/08/29/… Commented Mar 6, 2011 at 15:31
  • I expect to see my site styled with the style.css instead it's using the default. I'm not getting any error messages either. Commented Mar 6, 2011 at 15:34
  • 1
    Look whether the CSS file is served as 200 or 404. I assume the latter. Commented Mar 6, 2011 at 16:45
  • @AndiDog I see 200 in the terminal when I load a page. ([06/Mar/2011 11:33:57] "GET / HTTP/1.1" 200 611), but I'm not sure if that's what I am supposed to be looking for. How can I check for sure? Commented Mar 6, 2011 at 17:36
  • That's not the CSS. Just open up the web page source and click on the CSS file to see whether it loaded, or better use Live Http Headers for Firefox. Commented Mar 6, 2011 at 18:07

1 Answer 1

1

So, since your CSS file did load, I looked at your question again and found that you're just missing a = in your HTML.

<link rel"stylesheet" type="text/css" href="/static/style.css" />
        ^^^
Sign up to request clarification or add additional context in comments.

1 Comment

Newbie mistake. Thanks for taking the time to help out. Hopefully, I'll get better at this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.