【发布时间】:2020-01-04 00:47:23
【问题描述】:
所以我一直在试图弄清楚为什么图像不会显示,并且我已经观看并阅读了很多东西,但我仍然找不到任何东西。这是我在这里的第一个问题。感谢您的帮助
HTML
{% load static %}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Nikhil's Portfolio</title>
</head>
<body>
test
<img scr="{% static 'static/homepage/wpap.jpg' %}" alt="why is it not working">
<img scr="{% static 'static/homepage/download.jpg' %}" alt="why is it not working">
</body>
</html>
我网站的 url.py(不是应用程序 url)
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('homepage.urls'))
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
settings.py
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
我的文件是如何排列的 img of file organization
【问题讨论】:
-
我也在使用 django 3.0.1,而不是 3,如果有影响的话