【发布时间】:2019-02-10 23:48:24
【问题描述】:
Django Messages Framawork 未显示索引。
错误信息显示正常,但是我需要在数组之前获取信息的状态。
我尝试使用消息数组的索引,但没有显示。
有人知道我哪里出错了吗?
谢谢。
{% if messages %}
<script>
Swal.fire({
type: {{ messages.0.tags }}, <-------- Is not shown
title: 'Title',
html: '<ul class="messages" style="list-style: none;padding: 0;">\n' +
' {% for message in messages %}\n'+
' <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>\n'+
' <div class="notification is-{% if message.tags == 'error' %}danger{% else %}success{% endif %}">\n'+
' {{ message }}\n'+
' </div>\n'+
' </li>\n'+
' {% endfor %}\n' +
' </ul>'
})
</script>
{% endif %}
【问题讨论】:
-
检查
messages.0是否打印任何东西
标签: python django python-3.x django-templates