0
它以前工作正常,我不知道是什麼改變了,但我發現錯誤,現在的靜態文件加載=(請幫幫忙!Django的靜態CSS JS圖像文件不加載
使用Django 1.4
Urls.py
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()
Settings.py
STATIC_ROOT = '/root/abc/abc_app/sitestatic'
# URL prefix for static files.
STATIC_URL = '/static/'
# Additional locations of static files
STATICFILES_DIRS = (
'/root/abc/static/',
'/Users/blahusername/djangoproj/abc/static/',
)
了header.html
個<script type="text/javascript" src="/static/js/jquery-1.7.1.min.js"></script>
錯誤的瀏覽器:
GET file://localhost/static/js/jquery-1.7.1.min.js
Unsafe JavaScript attempt to access frame with URL file://localhost/Users/blahusername/djangoproj/abc/abc_app/templates/index.html from frame with URL http://www.youtube.com/embed/yyy. Domains, protocols and ports must match.
你可以執行命令:python manage.py findstatic js/jquery-1.7.1.min.js?什麼是輸出? –
在此處找到'js/jquery-1.7.1.min.js': /Users/blahusername/djangoproj/abc/static/js/jquery-1.7.1.min.js – user1678031