Python 加载django中其他静态文件引用的静态文件
在我的PythonDjango项目中,我有一个静态html文件(map.html)。在这个html文件中引用了其他静态文件。像这样:Python 加载django中其他静态文件引用的静态文件,python,django,Python,Django,在我的PythonDjango项目中,我有一个静态html文件(map.html)。在这个html文件中引用了其他静态文件。像这样: <!DOCTYPE html> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <script>L_PREFER_CANVAS = false; L_NO_TOUCH
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script>L_PREFER_CANVAS = false; L_NO_TOUCH = false; L_DISABLE_3D = false;</script>
<script src="mfiles/leaflet_002.js"></script>
<script src="mfiles/jquery.js"></script>
<script src="mfiles/bootstrap.js"></script>
<script src="mfiles/leaflet.js"></script>
<link rel="stylesheet" href="mfiles/leaflet.css">
<link rel="stylesheet" href="mfiles/bootstrap.css">
...
为什么在
index.html
中没有{%load staticfiles%}
# index.html
{% load staticfiles %}
<!DOCTYPE html>
<html><head>
<script src='{% static "mfiles/leaflet_002.js" %} '></script>
...
# django settings
STATICFILES_DIRS = (
os.path.join(SITE_ROOT, 'static'),
os.path.join(SITE_ROOT, 'm_app', 'static'),
)
#index.html
{%load staticfiles%}
...
#django设置
静态文件\u目录=(
join(SITE_ROOT,'static'),
join(SITE_ROOT,'m_app','static'),
)
能否显示文件层次结构的(相关部分)?完成,谢谢提示。见上文。完成。如上所述,仍然不起作用。我应该使用STATIC_URL='/STATIC/'进行调整吗?我得到的错误是以下格式:'[19/Jun/2018 08:16:55]“get/static/m_files/550_007.png HTTP/1.1”404 1687 `我再次修改它,您可以试试吗:)这是不可能的。我对我的问题作了一些澄清。该行不在index.html中,而是在map.html中,其中不能使用django模板语言。(我试过了)
m_project
|______> m_app
|______> __pychache__
|______> migrations
|______> static
|______> m_files ("this folder is referenced in map.html and django doens't see it")
|______> leaflet_002.js
|______> ...
|______> map.html ("this is the static html file referenced from template index.html")
|______> templates
|______> m_app
|______> index.html ("this is the template file I am talking about above")
|______> __init__.py
|______> admin.py
|______> apps.py
|______> models.py
|______> tests.py
|______> urls.py
|______> views.py
|______> m_project
|______> __pychache__
|______> __init__.py
|______> settings.py
|______> urls.py
|______> wsgi.py
|______> db.sqlite3
|______> manage.py
# index.html
{% load staticfiles %}
<!DOCTYPE html>
<html><head>
<script src='{% static "mfiles/leaflet_002.js" %} '></script>
...
# django settings
STATICFILES_DIRS = (
os.path.join(SITE_ROOT, 'static'),
os.path.join(SITE_ROOT, 'm_app', 'static'),
)