【问题标题】:Django Polls Tutorial Part 3: polls/templates/polls/index.html - What is this code? It's not pythonDjango Polls 教程第 3 部分:polls/templates/polls/index.html - 这段代码是什么?这不是蟒蛇
【发布时间】:2015-12-15 21:15:53
【问题描述】:

这是直接来自民意调查教程,我是编程新手,学习 Python 和 Django,这对我来说看起来很陌生。这是 JavaScript 吗?我还需要学习任何语言来学习 Django 吗?

投票/模板/投票/index.html

{% if latest_question_list %}
    <ul>
    {% for question in latest_question_list %}
        <li><a href="/polls/{{ question.id }}/">{{ question.question_text }}</a></li>
    {% endfor %}
    </ul>
{% else %}
    <p>No polls are available.</p>
{% endif %}

【问题讨论】:

标签: javascript python django


【解决方案1】:

如上所述,它是 Django 模板语言(大括号中的东西),因为它是一个模板,所以它在 HTML 中。

【讨论】:

    【解决方案2】:

    【讨论】:

      【解决方案3】:

      这是 Django 模板引擎(就像 Flask 中的 jinja)。花括号“{}”下的内容从应用程序中的views.py中获取值并呈现给html文件。

      【讨论】:

        猜你喜欢
        • 2016-12-24
        • 2016-01-14
        • 1970-01-01
        • 1970-01-01
        • 2014-07-05
        • 2014-03-11
        • 1970-01-01
        • 2012-09-06
        • 2013-10-20
        相关资源
        最近更新 更多