Jquery Django静态CSS JS图像文件未加载
它以前工作得很好,我不知道发生了什么变化,但现在静态文件加载=(请帮助 使用Django 1.4 url.pyJquery Django静态CSS JS图像文件未加载,jquery,django,django-staticfiles,Jquery,Django,Django Staticfiles,它以前工作得很好,我不知道发生了什么变化,但现在静态文件加载=(请帮助 使用Django 1.4 url.py from django.contrib.staticfiles.urls import staticfiles_urlpatterns urlpatterns += staticfiles_urlpatterns() 设置.py STATIC_ROOT = '/root/abc/abc_app/sitestatic' # URL prefix for static files. S
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()
设置.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>
根据您显示的浏览器错误,这看起来不像是django staticfiles问题,而是浏览器跨源策略/iframe和主机页访问存在问题。要确认:
- 在具有devtools(例如Chrome或Safari)的浏览器中,加载导致错误的页面
- 单击“资源”选项卡并在框架>(主框架的名称)>脚本下查找jquery脚本
- 单击网络选项卡后重新加载页面,并检查jQuery文件请求的HTTP状态
- 浏览器中的index.html URL错误是一个文件:///URL(file://localhost/Users/blahusername/djangoproj/abc/abc_app/templates/index.html )。由于跨源资源共享限制,大多数浏览器通常不允许从一个源加载的页面访问来自不同源的资源。每个文件:///URL被视为不同于其他所有文件:///,即使它们都引用了同一文件系统文件夹中的资源
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.