django试图把一张桌子放在一个视图中

时间:2014-11-02 20:42:45

标签: django

在我的views.py中:

def show(request):
    query_results=Emails.objects.all()

    #from py_utils import open_py_shell;open_py_shell.open_py_shell()

    context = { 'query_result' : query_results }
    return render(request, 'show.html', context)
show.html中的

<table id="example" class="display" cellspacing="0" width="100%">
    <thead>
        <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
        </tr>
    </thead>
    <tfoot>
        <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
        </tr>
    </tfoot>
    <tbody>
        {% for item in query_result %}
        <tr>
            <td>Ohad</td>
            <td>{{ item.email }}</td>
            <td>{{ item.baseurl }}</td>
        </tr>
        {% endfor %}
    </tbody>
</table>

电子邮件对象有电子邮件字段和baseurl字段,但似乎我无法加载它, 我检查了并且在query_result我有一个电子邮件对象列表,只是不能把它放在表中,有什么帮助吗?

0 个答案:

没有答案