Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django数据库连接问题_Django_Django Database - Fatal编程技术网

Django数据库连接问题

Django数据库连接问题,django,django-database,Django,Django Database,我试着自学Python和Django,到目前为止我做得还不错,但我遇到了一个障碍。我一直在关注Django MVA,也在使用“Hello Web App”一书,并在需要时搜索Web以寻求帮助,但我似乎无法通过这一步,所以接下来 我用Django建立了一个非常简单的web应用程序,它只有一个表和一个模型。我可以设置管理模块,我可以在管理视图和shell中查看和操作数据库中的数据,但是当我启动站点时,我的视图似乎找不到任何数据 我的观点 from django.shortcuts import re

我试着自学Python和Django,到目前为止我做得还不错,但我遇到了一个障碍。我一直在关注Django MVA,也在使用“Hello Web App”一书,并在需要时搜索Web以寻求帮助,但我似乎无法通过这一步,所以接下来

我用Django建立了一个非常简单的web应用程序,它只有一个表和一个模型。我可以设置管理模块,我可以在管理视图和shell中查看和操作数据库中的数据,但是当我启动站点时,我的视图似乎找不到任何数据

我的观点

from django.shortcuts import render, render_to_response
from django.http import HttpRequest, HttpResponse
from django.template import RequestContext
from datetime import datetime
from app.models import Order
from app.models import *;



def MMIR(request):
    order_list = Order.objects.all();
    return render(request, 'app/MMIR.html',{'oder_list':order_list});
我的模板:MMIR.html

{% extends "app/layout.html" %}
{% block content %}

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>MMIRs</title>
</head>
<body>
    <h2>MMIRs</h2>
        <ul>
           {% for order in order_list %}
               <li>{{order.MMIR}}</li>
            {%empty%}
                <li>Sorry there are no orders to display</li>
           {% endfor %}
         </ul>

</body>
</html>
{% endblock %}  
和my models.py:

from django.db import models

# Create your models here.

class Order(models.Model):
    MMIR = models.CharField(max_length=10)
    AWB = models.CharField(max_length=25)
    Shipper = models.CharField(max_length=20)
    Vendor = models.CharField(max_length=25)
    order_type = models.CharField(max_length=25) 
当我进入MMIR页面时,当我知道数据库中有订单时,我总是会收到“对不起,没有要显示的订单”消息。我找遍了所有我能想到的地方,但我似乎不知道我做错了什么。谁能给我指出正确的方向吗

谢谢
Max

在此处查找输入错误:

返回呈现(请求'app/MMIR.html',{'order\u list':order\u list})

换成

return render(request, 'app/MMIR.html',{'order_list':order_list});

我想你的身体会很好。

非常感谢!我想我看不见森林了。我已经盯着这个看了好几天了,从来没有见过那个lol
return render(request, 'app/MMIR.html',{'order_list':order_list});