本文整理汇总了Python中django.contrib.messages.utils.get_level_tags方法的典型用法代码示例。如果您正苦于以下问题:Python utils.get_level_tags方法的具体用法?Python utils.get_level_tags怎么用?Python utils.get_level_tags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.contrib.messages.utils
的用法示例。
在下文中一共展示了utils.get_level_tags方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: enable
# 需要导入模块: from django.contrib.messages import utils [as 别名]
# 或者: from django.contrib.messages.utils import get_level_tags [as 别名]
def enable(self):
super().enable()
# LEVEL_TAGS is a constant defined in the
# django.contrib.messages.storage.base module, so after changing
# settings.MESSAGE_TAGS, update that constant also.
self.old_level_tags = base.LEVEL_TAGS
base.LEVEL_TAGS = utils.get_level_tags()
示例2: styleguide
# 需要导入模块: from django.contrib.messages import utils [as 别名]
# 或者: from django.contrib.messages.utils import get_level_tags [as 别名]
def styleguide(request):
now = timezone.now() + timedelta(-1)
domain = mock.Mock(domain="example.com")
# create a bunch of mocked inboxes
inboxes = [
mock.Mock(
inbox="qwerty",
domain=domain,
get_bools_for_labels=(("new", False),),
last_activity=now,
form=InboxEditForm(request),
),
mock.Mock(
inbox="qwerty",
domain=domain,
get_bools_for_labels=(("disabled", True),),
last_activity=now,
form=False,
),
mock.Mock(
inbox="qwerty",
domain=domain,
get_bools_for_labels=(("new", True), ("pinned", True)),
last_activity=now,
form=False,
),
]
# emails
emails = [
mock.Mock(
inbox=inboxes[0],
get_bools_for_labels=(("important", True),),
received_date=now,
),
mock.Mock(
inbox=inboxes[0],
get_bools_for_labels=(("important", False),),
received_date=now,
),
]
# attachments
attachments = [
mock.Mock(id=0, filename=("a" * 100), content_type="blah/blah", get_children=[]),
mock.Mock(id=0, filename="a", content_type=None, get_children=[]),
]
context = {
"inboxes": inboxes,
"emails": emails,
"attachments": attachments,
"form": Form(),
"message_types": [(k, get_level_tags()[v]) for k, v in DEFAULT_LEVELS.items() if k != 'DEBUG'],
}
return TemplateResponse(request, 'inboxen/styleguide.html', context)