84669 personnes étudient
152542 personnes étudient
20005 personnes étudient
5487 personnes étudient
7821 personnes étudient
359900 personnes étudient
3350 personnes étudient
180660 personnes étudient
48569 personnes étudient
18603 personnes étudient
40936 personnes étudient
1549 personnes étudient
1183 personnes étudient
32909 personnes étudient
运行:
uwsgi --http :8080 --module DDoS.wsgi
然后访问localohsot:8080/ddos/加载不出静态文件
localohsot:8080/ddos/
我的项目目录结构:
配置文件STATIC路由:
Django Version == 1.7.6
Django Version
请问如何解决?谢谢
光阴似箭催人老,日月如移越少年。
以前遇到过类似的问题,解决方案如下(仅供参考):
urls.py
from django.conf.urls import include, url from django.contrib import admin from django.conf.urls.static import static from django.conf import settings urlpatterns = [ url(r'^admin/', include(admin.site.urls)), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) + static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)
settings.py
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'backend/static') MEDIA_URL = '/upload/' MEDIA_ROOT = os.path.join(BASE_DIR, 'backend/upload')
settings配置STATIC_URL和STATICFILES_DIRS
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), )
在templates页面这样写
<script src="{{ STATIC_URL }}js/xxx.js"></script>
以前遇到过类似的问题,解决方案如下(仅供参考):
urls.py
settings.py
settings配置STATIC_URL和STATICFILES_DIRS
在templates页面这样写