urls 中
url(r'getnum',views.getnum)
views.py 中添加对应的函数
def getnum(request):
num = 5
context_num = {
'num':num
}
return render(request,'num_ys.html',context=context_num)
html 中代码
<body>
{# 乘法 #}
<h2> {{num}} 当前的值</h2>
<h3>进行运算后的值 : {% widthratio num 1 5 %}</h3>
{# 除法 #}
<h2> {{num}} 当前的值</h2>
<h3>进行运算后的值 : {% widthratio num 5 1 %}</h3>
</body>
{%widthratio 数 分母 分子 %}
2020-05-14