settings.py中
DEBUG = False
STATIC_URL = '/static/'
# 项目根目录下的static文件夹
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = (
os.path.join(BASE_DIR,"static").replace("\","/"),
)
urls.py中
from django.views import static
from django.conf import settings
urlpatterns = [
url(r'^static/(?P<path>.*)$', static.serve, {'document_root': settings.STATIC_ROOT }, name='static'),
]