如何解决Django中的图像404错误
- 论坛
- 如何解决Django中的图像404错误
8 浏览
如何解决Django中的图像404错误
我卡在这个404错误上了
当我尝试使用检查找出错误时,我得到了这个
我的设置代码:
STATIC_URL = '/static/' MEDIA_URL = '/images/' STATICFILES_DIR =[ os.path.join(BASE_DIR, 'static') ]
我在HTML文件中引用图片的方法:
我的URL文件:
urlpatterns = [ path('admin/', admin.site.urls), path('', include('amitians.urls')), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
我在静态文件夹中有一个图片文件夹
在我的检查页面上,文件类型显示为text/html,尽管明显是.png格式的。不确定是否相关,但在这里
以及在命令提示符中显示的错误如下:
Quit the server with CTRL-BREAK. [12/Dec/2020 13:44:45] "GET / HTTP/1.1" 200 2616 [12/Dec/2020 13:44:45] "GET /static/images/logo.png HTTP/1.1" 404 1772
我尝试了许多stackoverflow上的解决方案,但似乎无法使其工作
我还尝试过直接在静态文件夹中使用我的图片文件。
如果有人能帮忙,我会很高兴!