在Django中使用变量更改HTML

sup*_*er9 1 python django django-templates

我有字典最新状态:

{'What': 10, "Study'": 10, 'all': 10, 'to': 10, "facebook'": 10, 'has': 10, 'worth': 20, 'hurting': 10 }
Run Code Online (Sandbox Code Playgroud)

我正在尝试通过在模板中执行以下操作来使文本云化:

{% for word,count in latest_status.items %}
<style="font-size:{{ count }}px"> {{ word }}</style> 
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用dict的计数来控制字体大小,但它似乎不起作用。

Ori*_*Ori 5

<style>标记用于引入包含样式定义的块(或外部资源)。您需要将文本封装在某种形式的演示标签中,例如:

{% for word,count in latest_status.items %}
<p style="font-size:{{ count }}px;"> {{ word }}</p>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)