You are not logged in.

Change Language:

Profile for shehzad

Name shehzad
Email Address n/a
Posts1
  • Help on making static files work in Django‏
    Board » Getting Started » Setup and Configuration
    I am a technical developer, learning Django. I have having a hard time making static files work in Django in it's Development server.

    I want to use a CSS stylesheet for my base.html template. I have the following written in my urls.py.

    from django.conf import settings

    urlpatterns += patterns('',
    (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': 'static'})
    )
    In my setting,py I have written the following.

    SITE_ROOT = os.path.realpath(os.path.dirname(__file__))
    MEDIA_ROOT = os.path.join(SITE_ROOT, 'static')

    TEMPLATE_DIRS = (
    os.path.join(SITE_ROOT, 'templates'),
    )

    And in mybase.html I have written

    <link href="/home/shehzad/djcode/c2duo_crm/media/css/style.css" rel="stylesheet" type="text/css">

    Yet for some reason it stll does not work (a web page with no stylesheet imported to the webpage). As you can tell, I have been looking at http://docs.djangoproject.com/en/dev/howto/static-files/, but still cannot make it work. Unless I am missing something crucial.


Powered by Sphene Community Tools