从这个主题的类似标题的数量判断,这似乎是一个混乱的来源,但是尝试用django开发服务器在静态文件上找到的所有内容我几乎放弃了希望!
所以我的静态文件来自C:/ Users/Dan/seminarWebsite/static /,其中我有图像的子文件夹,css等.
设置:
STATIC_ROOT = 'C:/Users/Dan/seminarWebsite/static/'
STATIC_URL = '/static/'
Run Code Online (Sandbox Code Playgroud)
静态文件应用程序也处于活动状态.
URLS:
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()
Run Code Online (Sandbox Code Playgroud)
模板:
"{{ STATIC_URL }}images/vision.jpeg"
Run Code Online (Sandbox Code Playgroud)
但是,只有一个断开的链接出现在此地址:http://127.0.0.1:8000/homepage/images/vision.jpeg我不认为它应该在该地址(主页是静态图像文件被调用的页面的URL名称).