English 中文(简体)
Noobie需要帮助伪造简单的字典/django代码。 为什么要赢得这一看法?
原标题:Noobie needs help debugging simple python/django code. Why won t this view work?
问题回答

什么是:

def display_request_meta_data(request):
    meta_data = request.META.items()
    meta_data.sort()
    for x in meta_data: # you were missing a semi column
        # print x  # wasn t working, so I tried using a logger instead.
        logger.error(x)
    t = get_template( http_meta_data_table.html )
    html = t.render(Context({ meta_data : meta_data})) # the dict doesn t exitst
    return HttpResponse(html)

在 html中,有没有:

<html>
<head>
    <title>HTTP Meta Data</title>
</head>
<body>
    <table>
        {% for key, value in meta_data %}
            <tr><td>{{key}}</td><td>{{value}}</td></tr>
        {% endfor %}
    </table>
</body>

</html>

这实际上与干.无关,这是非常基本的错误。 采用框架进行学习方案是海事组织的一个坏想法。 你们应该先学习基本知识,或者说你学习好像是平墙。

Django是一个容易学习的框架,但它假定你知道Adhur。

<代码>meta_data_dict未作界定。 很可能通过<代码>meta_data至t.render/code>。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...