路径:
helloworld/
---------------init.py
---------------views.py
---------------settings.py
---------------urls.py
---------------templates/
-----------------------------index.html
---------------static/
-----------------------css/
-----------------------------common.csss
-----------------------js/
--------------------------common.js
办法:
1. settings.py最下方STATIC_URL下面补上
STATIC_ROOT = os.path.join(os.path.dirname(__file__),'static')
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('\\','/') ),
)
2. urls.py文件补以下两行
import settings
(r'^static/(?P.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),
3.html引用办法