【发布时间】:2014-09-15 10:01:13
【问题描述】:
即使图片的网址是准确的,我也会不断收到 404 错误。是的,我查看了官方 django 文档和大量 stackoverflow 帖子。我无法从这些中弄清楚。如果有人能破译instructions are saying 做什么,我将不胜感激,因为他们似乎缺少信息。
index.html:
#I have tried static and staticfiles
{% load static %}
#a lot of code later...
<img border="0" src="{% static "logo.png" %}" alt="TMS" width="125" height="80">
目录结构:
projectname
->__init__.py, settings.py, ...
manage.py
db.sql3
app_name
-> admin.py, models.py, views.py, templates->index.html, ...
static
->logo.png
我在 settings.py 和 'django.contrib.staticfiles' 中唯一关于静态的东西:
STATIC_URL = '/static/'
我的 views.py 文件具有返回 HttpResponse(t.render(c)) 的索引函数,其中 t 是 index.html 模板,c 是上下文。这些可能是问题吗?
生成的网址是这样的:http://127.0.0.1:8000/static/logo.png
【问题讨论】:
标签: python django image static http-status-code-404