settings.py文件中确保包含以下内容:
#INSTALLED_APPS中要有'django.contrib.staticfiles',
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"),
)
STATIC_URL = '/static/'
urls.py中末尾加入这个:
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()
我的static目录实在project/static,并不是在project/app/static,后者没有验证,我的这种成功了。
以上仅供参考。
参考资料:http://blog.yangyubo.com/2012/07/26/django-staticfiles/