2

I am trying to get the CSS sheet to load on my development computer. It is in the media directory as media/base.css. In my base/base.html template, I have:

<link href="media/base.css" rel="stylesheet" type="text/css" />

I found this page, but that didn't fix it. Any ideas?

1 Answer 1

3

if media/ is your project media directory, then in the template use

<link href="{{ MEDIA_URL }}base.css" rel="stylesheet" type="text/css" />

this is considering you have passed RequestContext to your template, ex:

def some_view(request):
    # ...
    return render_to_response('my_template.html',
                              my_data_dictionary,
                              context_instance=RequestContext(request))

You will also need to have static urls served when running on the localdev server. Include this in your urls.py:

from django.conf import settings
if settings.DEBUG:
    urlpatterns += patterns('',
                            url(r'^%s(?P<path>.*)$' % settings.MEDIA_URL[1:],
                                'django.views.static.serve',
                                {'document_root': settings.MEDIA_ROOT, 'show_indexes': True})
                            )
Sign up to request clarification or add additional context in comments.

Comments

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.