【发布时间】:2014-04-23 18:46:25
【问题描述】:
首先让我说我是一个想学习 django 的学生... 我通过教程完成了我的应用程序,但我的模板中显示的图像有问题,它只是显示没有图像的框架......这是我的 html 代码:
<aside>
<h4>Historico</h4>
{% for month in months %}
<p><a href="{url 'blog.views.month' month.0 month.1}">{{ month.2 }}</a></p>
{% endfor %}
<h4>Sobre mi</h4>
<img class="pic" src="{{ STATIC_URL }}/static/img/foto.jpg" alt="foto"/>
<img class="picbig" src="{{ STATIC_URL }}/static/img/foto.jpg" alt="foto grande"/>
<p>Soy un doge san OP platino IV lan pls</p>
</aside>
我的图片“foto.jpg”没有显示,这是我的静态设置.py
STATIC_URL = '/static/'
STATICFILES_DIRS = (
"C:/Users/Abdul Hamid/PycharmProjects/misitioweb/static",
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
我的img在这样的文件夹中
`C:\Users\User-Name\PycharmProjects\misitioweb\`
`blog-
-templtates
--frontpage.html
--otherthing.html
-__init__.py
-admin.py
-models.py
-test.py
-views.py
mysite-
-__init__.py
-settings.py
-urls.py
-wsgi.py
manage.py
-etc..
static-
--img
---foto.jpg
`
我一直在尝试更改 img 标记中的代码以获得不同的结果,例如将静态文件夹加载到模板中,如下所示:
{{from static import staticfiles}}
我做错了什么,我已经尝试搜索更多信息,但没有任何效果...请帮助我! 反正 谢谢你的时间
【问题讨论】:
-
你应该阅读官方的 django 教程。挺好的,不长,很容易理解。我不会告诉你在哪里,但你会在这里找到答案:docs.djangoproject.com/en/1.6/intro/tutorial01
标签: python django image templates static