端阳月七 2021-05-18 17:18 采纳率: 80%
浏览 166
已采纳

django写的前端页面显示不出数据库的信息?

前端页面:

{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="{% static 'plugins/bootstrap-3.3.7-dist/css/bootstrap.min.css' %}">
</head>
<body>
<div class="container">
    <h1>编辑物资信息</h1>
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <a href="/add_store/" class="btn btn-primary">添加仓库信息</a>
            <table style="margin-top: 10px;" class="table table-bordered table-striped table-hover">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>仓库编号</th>
                    <th>仓库地址</th>
                    <th>物资编号</th>
                    <th>物资数量</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {% for store in store %}
                <tr>
                    <td>{{ forloop.counter }}</td>
                    <td>{{ store.warehouseId }}</td>
                    <td>{{ store.warehouseAddress }}</td>
                </tr>
                {% endfor %}
                {% for good in goods %}
                <tr>
                    <td>{{ good.type_name }}</td>
                    <td>{{ good.num }}</td>
                    <td>
                        <a href="{% url ''  %}" class="btn btn-warning">编辑</a>
                        <a href="{% url ''  %}" class="btn btn-danger">删除</a>
                    </td>
                </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
</body>
</html>

models:

class warehouseInfo(models.Model):
    warehouseId = models.IntegerField(verbose_name=u'仓库编号',null=True)
    warehouseAddress = models.CharField(verbose_name=u'仓库地址', max_length=20, null=True)

views:

def warehouse(request):
    store = models.warehouseInfo.objects.all()
    goods = models.logisticsInfo.objects.all()
    return render(request, 'warehouse.html',{'store':store,'goods':goods})

urls:

url(r'',include('warehouse.urls')),

 明明数据库里已经添加了信息,但是页面上就是没有,救救孩子吧!

 

 

 

  • 写回答

2条回答 默认 最新

  • CSDN专家-黄老师 2021-05-18 17:19
    关注

    你在视图里面print(goods )看看数据

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 Matlab打开默认名称带有/的光谱数据
  • ¥50 easyExcel模板 动态单元格合并列
  • ¥15 res.rows如何取值使用
  • ¥15 在odoo17开发环境中,怎么实现库存管理系统,或独立模块设计与AGV小车对接?开发方面应如何设计和开发?请详细解释MES或WMS在与AGV小车对接时需完成的设计和开发
  • ¥15 CSP算法实现EEG特征提取,哪一步错了?
  • ¥15 游戏盾如何溯源服务器真实ip?需要30个字。后面的字是凑数的
  • ¥15 vue3前端取消收藏的不会引用collectId
  • ¥15 delphi7 HMAC_SHA256方式加密
  • ¥15 关于#qt#的问题:我想实现qcustomplot完成坐标轴
  • ¥15 下列c语言代码为何输出了多余的空格