Django民意测验教程第3部分:Polls/templates/Polls/index.html-这段代码是什么?它&

Django Polls Tutorial Part 3: polls/templates/polls/index.html - What is this code? It's not python

本文关键字:Polls 段代码 代码 是什么 index 教程 民意测验 3部 Django templates html-      更新时间:2023-09-26

这是直接从民意测验教程中获得的,我是编程新手,学习Python和Django,这对我来说很陌生。这是JavaScript吗?我还需要学习任何一种语言来学习Django吗?

polls/templates/polls/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 %}

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

根据注释,它是:Django模板语言

https://docs.djangoproject.com/en/1.9/topics/templates/#the-django模板语言

这是Django模板引擎(就像Flask中的jinja)。花括号"{}"下的填充从应用程序中的views.py中获取值,并呈现到html文件中。