首页 > 解决方案 > 尝试从 django 数据库显示图像时的消息:“znet”属性没有与之关联的文件

问题描述

znet 是存储我们图像的地方

from .models import Contactus

def contact(request):
    cont = Contactus.objects.all()
    context={'cont':cont}
    
    return render(request,'contactus.html',context)   
 {% for cont in cont %}

            <div class="  flex-item-right ">
                <div class="thisweekabout"><img src="{{cont.znet.url}}" style="height: 100%; width: 100%;" alt="">
                </div>

            </div>
            <hr>

 {% endfor %} 

标签: django-rest-framework

解决方案


推荐阅读