django1.4配置静态文件路径
配的真心蛋疼
首先,得把静态文件夹如static 单独放在你的app里面,(就是startapp命令建立那个文件夹下)
然后,settings.py:
STATIC_ROOT =r'E:/Py_workspace/note_site/src/notesite/notesapp/static/'
STATIC_URL = '/static/'
# Additional locations of static files
STATICFILES_DIRS = (
r'E:/Py_workspace/note_site/src/notesite/notesapp',
)
再后来,urls.py:
from django.conf import settings
from django.conf.urls.static import static
urlpatterns+=static(settings.STATIC_URL,document_root=settings.STATIC_ROOT)
使用:<link rel="stylesheet" type="text/css" href="/static/css/style.css" />