[英]Django static path of the image is not working
I am trying to load the static path of the image which is not working but the static path of the css files are working perfectly.我正在尝试加载无法正常工作的图像的 static 路径,但 css 文件的 static 路径工作正常。 I have tried every different way but still getting 404我尝试了各种不同的方法,但仍然收到 404
this is i am trying to access the image which is inside the folder of ip
in static folder这是我正在尝试访问 static 文件夹中ip
文件夹内的图像
<div class="col-auto">
<img src="{% static 'ip/best.png' %}"/>
</div>
I have load the static block above我已经加载了上面的 static 块
{% load static %}
and the settings.py configuraion of static url和static url的settings.py配置
STATIC_URL = '/static/'
STATICFILES_DIRS=[
os.path.join(BASE_DIR,'static')
]
I believe this is a media file so you need to add this to the project settings:我相信这是一个媒体文件,因此您需要将其添加到项目设置中:
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
VENV_PATH = os.path.dirname(BASE_DIR)
STATIC_ROOT = os.path.join(VENV_PATH, 'static_root')
you can add the folder to it and refer to it您可以将文件夹添加到其中并参考它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.