当您通过django admin保存某些内容时,您将在页面顶部显示“保存”或“请更正错误”的此引导警报栏。如何在get / post参数中传递一些内容以显示在这样的栏中?
答案 0 :(得分:1)
您正在寻找Django' Messaging Framework。
以下是文档中的一些代码:
from django.contrib import messages
messages.add_message(request, messages.INFO, 'Hello world.')
# Shortcut methods
messages.debug(request, '%s SQL statements were executed.' % count)
messages.info(request, 'Three credits remain in your account.')
messages.success(request, 'Profile details updated.')
messages.warning(request, 'Your account expires in three days.')
messages.error(request, 'Document deleted.')