django1.4测试环境 css样式,图片路径问题解决

1. 设置 STATIC_ROOT = os.path.join(os.path.dirname(__file__),'static')

2. 设置 STATIC_URL = '/static/'

3. 配置 STATICFILES_DIRS

 

STATICFILES_DIRS = (
    ('css',os.path.join(STATIC_ROOT,'css').replace('\\','/') ),  
    ('js',os.path.join(STATIC_ROOT,'js').replace('\\','/') ), 
    ('images',os.path.join(STATIC_ROOT,'images').replace('\\','/') ), 
    ('upload',os.path.join(STATIC_ROOT,'upload').replace('\\','/') ), 
)

网页中代码如下: 

<script type="text/javascript" src="/static/js/myjs.js"></script> 

  

posted @ 2013-01-17 15:06  季石磊  阅读(264)  评论(0编辑  收藏  举报