摘要: 在 urls 中注册 url(r'getstr',views.getstr) 在 views.py 中添加函数 def getstr(request): string = 'abc' string_2 = 'ABC' context_str = { 'string':string, 'string_ 阅读全文
posted @ 2020-05-14 20:38 Hany47315 阅读(415) 评论(0) 推荐(0)
摘要: {% ifequal 数值 数值 %} <body> {# 判断是否相等 #} num 当前的值 {{ num }}<br/> {% ifequal num 5 %} {# 判断 num 是否等于 5#} num 的值是 5 {% endifequal %} </body> {% ifnotequa 阅读全文
posted @ 2020-05-14 20:13 Hany47315 阅读(366) 评论(0) 推荐(0)
摘要: urls 中 url(r'getnum',views.getnum) views.py 中添加对应的函数 def getnum(request): num = 5 context_num = { 'num':num } return render(request,'num_ys.html',cont 阅读全文
posted @ 2020-05-14 19:41 Hany47315 阅读(362) 评论(0) 推荐(0)
摘要: if else 格式 {% if 条件 %} <标签>语句</标签> {%else%} <标签>语句</标签> {%endif} 标签都可以添加样式 {% for stu in students %} {% if forloop.first %} <li style="color: chartreu 阅读全文
posted @ 2020-05-14 12:20 Hany47315 阅读(900) 评论(0) 推荐(0)
摘要: 当查找的数据不存在,返回为 空时 在 html 中使用 {%empty%} 语句 进行显示 def getstudents(request): students = Student.objects.all().filter(s_name = 'qwer') # 指定一个不存在的值, # studen 阅读全文
posted @ 2020-05-14 11:59 Hany47315 阅读(388) 评论(0) 推荐(0)