繁体   English   中英

尝试在Django模板中显示静态文件夹中的图像时遇到麻烦

[英]trouble trying to show an image from my static folder in a django template

即时通讯试图显示我的模板中的图像,如果个人资料没有任何图片。 我的模板中有此代码

{% if not profileForm.avatar %}
   <img src="{% static 'img/empty-profile-picture.png' %}" alt="" />
{% endif %}

我得到那个错误

Template error:
In template /home/jaime/djcode/urgencias/templates/usuarios/profile_edit.html, error at line 68
   Invalid block tag: 'static', expected 'elif', 'else' o 'endif'

你有一个错字-关键字是static ,而不是satic

我也通过将丢失的{% load staticfiles %}放在子模板的开头来解决了这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM